R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Course / Section 1: Discrete Probability / Section 1 Overview

Section 1 Overview

Section 1 introduces you to Discrete Probability. Section 1 is divided into three parts:

[][* Introduction to Discrete Probability*] A discrete probability distribution counts occurrences that have countable or finite outcomes. [][* Combinations and Permutations*] When the order doesn’t matter, it is a Combination. When the order does matter it is a Permutation] [][* Addition Rule and Monty Hall*] https://www.varsitytutors.com/hotmath/hotmath_help/topics/addition-rule-of-probability https://www.mathgoodies.com/lessons/vol6/addition_rules Google Monty Hall problem

After completing Section 1, you will be able to:

    apply basic probability theory to categorical data.
    perform a Monte Carlo simulation to approximate the results of repeating an experiment over and over, including simulating the outcomes in the Monty Hall problem.
    distinguish between: sampling with and without replacement, events that are and are not independent, and combinations and permutations.
    apply the multiplication and addition rules, as appropriate, to calculate the probably of multiple events occurring.
    use sapply() instead of a for loop to perform element-wise operations on a function.

There are 3 assignments that use the DataCamp platform for you to practice your coding skills. There are also some quick probability calculations for you to perform directly on the edX platform as well, and there is a longer set of problems at the end of section 1.

This section corresponds to the following section of the course textbook. https://rafalab.github.io/dsbook/probability.html#discrete-probability

We encourage you to use R to interactively test out your answers and further your learning.

Course / Section 1: Discrete Probability / 1.1 Introduction to Discrete Probability

Discrete Probability

We start by covering some basic principles related to categorical data. This subset of probability is referred to as [][discrete probability]. It will help us understand the probability theory we will later introduce for numeric and continuous data, which is more common in data science applications. Discrete probability is more useful in card games and we use these as examples. The word probability is used in everyday language. For example, Google’s auto complete of, what are the chances of, gives us getting pregnant, having twins, and rain tomorrow. Answering questions about probability is often hard, if not impossible. Here, we discuss a mathematical definition of probability that does permit us to give precise answers to certain questions.

For example, if I have two red beads and three blue beads inside an urn and I pick one at random, what is the probability of picking a red one? Our intuition tells us that the answer is 2/5, or 40%. A precise definition can be given by noting that there are five possible outcomes of which two satisfy the condition necessary for the event “pick a red bead.” Because each of the five outcomes has the same chance of occurring, we conclude that the probability is 0.4 for red and 0.6 for blue.

[][A more tangible way to think about the probability of an event is as a proportion of times the event occurs when we repeat the experiment over and over independently and under the same conditions]. Before we continue, let’s introduce some notation. We use the notation probability of A to denote the probability of an event A happening. We use the very general term event to refer to things that can happen when something happens by chance.

For example, in our previous example, the event was picking a red bead. In a political poll, in which we call 100 likely voters at random, an example of an event is calling 48 Democrats and 52 Republicans. [][**In data science applications, we will often deal with continuous variables]. In these cases, events will often be things like, is this person taller than 6 feet? In this case, we write events in a more mathematical form. For example, x greater than 6. We’ll see more of these examples later. Here, we focus on categorical data and discrete probability.

[][Textbook link]

This video corresponds to the textbook section on discrete probability External link. https://rafalab.github.io/dsbook/probability.html#discrete-probability

[][Key points]

The probability of an event is the proportion of times the event occurs when we repeat the experiment independently under the same conditions.
Pr(A) = probability of event A
An event is defined as an outcome that can occur when when something happens by chance.
We can determine probabilities related to discrete variables (picking a red bead, choosing 48 Democrats and 52 Republicans from 100 likely voters) and continuous variables (height over 6 feet).

in data science we will often deal with continuous variables.png

Monte Carlo Simulations

Computers provide a way to actually perform the simple random experiments, such as the one we did before. Pick a bead at random from a bag or an urn with 3 blue beads and 2 red ones. [][Random number generators] permit us to mimic the process of picking at random. An example in R is the sample() function. We demonstrate its use showing you some code. First, use the rep() function to generate the urn. We create an urn with 2 red and 3 blues. You can see when we type beads we see this. Now, we can use a sample() function to pick one at random. If we type sample beads comma 1, in this case, we get a blue. This line of code produces one random outcome. Now, we want to repeat this experiment over and over.

However, it is, of course, impossible to repeat forever. Instead, we repeat the experiment a large enough number of times to make the results practically equivalent to doing it over and over forever. [][This is an example of a Monte Carlo simulation]. Note that much of what mathematical and theoretical statisticians study–something we do not cover in this course–relates to providing rigorous definitions of practically equivalent, as well as studying how close a large number of experiment gets us to what happens in the limit, the limit meaning if we did it forever. [][********Later in this module, we provide a practical approach to deciding what is large enough********].

To perform our first Monte Carlo simulation, we use the replicate() function. This permits us to repeat the same task any number of times we want. Here, we repeat the random event 10,000 times. We set B to be 10,000, then we use the replicate() function to sample from the beads 10,000 times. We can now see if, in fact, our definition is in agreement with this Monte Carlo simulation approximation. We can use table(), for example, to see the distribution. And then we can use prop.table() to give us the proportions. And we see that, in fact, the Monte Carlo simulation gives a very good approximation with 0.5962 for blue and 0.4038 for red. We didn’t get exactly 0.6 and exactly 0.4, but statistical theory tells us that, if we make B large enough, we can get as close as we want to those numbers. We just covered a simple and not very useful example of Monte Carlo simulations.

But we will use Monte Carlo simulation to estimate probabilities in cases in which it is harder to compute the exact ones. Before we go into more complex examples, we still use simple ones to demonstrate the computing tools available in R. Let’s start by noting that we don’t actually have to use replicate() in this particular example. This is because the function sample() has an argument that permits us to pick more than one element from the urn. However, by default, this selection occurs without replacement. After a bead is selected, it is not put back in the urn. Note what happens when we ask to randomly select 5 beads. Let’s do it over and over again. Let’s do it three times. This results in a rearrangement that always has three blue and two red beads. If we asked for six beads, then we get an error. It tells us you don’t have enough beads in here to get six.

This is because it’s doing it without replacement. However, this function, the sample function, can be used directly–again, without the replicate–to repeat the same experiment of picking 1 out of 5 beads over and over under the same conditions. To do this, we sample with replacement. After we pick the bead we put it back in the urn. We can tell sample to do this by changing the replace = argument which defaults to false to true. We do it like this. And when we do this, we see that we get very similar answers to what we got using the replicate function.

[][Textbook link]

This video corresponds to the textbook section on Monte Carlo simulations. https://rafalab.github.io/dsbook/probability.html#monte-carlo-simulations

[][Key points]

Monte Carlo simulations model the probability of different outcomes by repeating a random process a large enough number of times that the results are similar to what would be observed if the process were repeated forever.

The sample() function draws random outcomes from a set of options.
The replicate() function repeats lines of code a set number of times. It is used with sample() and similar functions to run Monte Carlo simulations.

Video code

Note that your exact outcome values from the Monte Carlo simulation will differ because the sampling is random.

beads <- rep(c(“red”, “blue”), times = c(2,3)) # create an urn with 2 red, 3 blue beads # view beads object sample(beads, 1) # sample 1 bead at random

B <- 10000 # number of times to draw 1 bead events <- replicate(B, sample(beads, 1)) # draw 1 bead, B times tab <- table(events) # make a table of outcome counts tab # view count table prop.table(tab) # view table of outcome proportions

beads = rep(c("red", "blue"), times = c(2, 3) )


sample(beads, 100, replace = T)
##   [1] "blue" "blue" "red"  "blue" "blue" "blue" "blue" "blue" "blue" "blue"
##  [11] "red"  "blue" "blue" "blue" "blue" "blue" "blue" "red"  "blue" "blue"
##  [21] "blue" "blue" "red"  "blue" "blue" "blue" "blue" "red"  "blue" "blue"
##  [31] "red"  "blue" "blue" "blue" "blue" "blue" "red"  "blue" "red"  "red" 
##  [41] "blue" "red"  "blue" "blue" "blue" "red"  "blue" "blue" "blue" "blue"
##  [51] "red"  "red"  "red"  "blue" "blue" "blue" "red"  "blue" "blue" "blue"
##  [61] "blue" "blue" "red"  "blue" "blue" "blue" "blue" "red"  "red"  "red" 
##  [71] "blue" "blue" "blue" "red"  "red"  "red"  "red"  "blue" "blue" "red" 
##  [81] "red"  "blue" "blue" "blue" "blue" "red"  "red"  "blue" "red"  "blue"
##  [91] "blue" "blue" "red"  "red"  "blue" "blue" "red"  "blue" "red"  "red"
tab = table(sample(beads, 10000, replace = T))
prop.table(tab)
## 
##   blue    red 
## 0.6037 0.3963

Setting the Random Seed

The set.seed() function

Before we continue, we will briefly explain the following important line of code:

set.seed(1986)

Throughout this book, we use random number generators. This implies that many of the results presented can actually change by chance, which then suggests that a frozen version of the book may show a different result than what you obtain when you try to code as shown in the book. This is actually fine since the results are random and change from time to time. However, if you want to to ensure that results are exactly the same every time you run them, you can set R’s random number generation seed to a specific number. Above we set it to 1986. We want to avoid using the same seed every time. A popular way to pick the seed is the year - month - day. For example, we picked 1986 on December 20, 2018: 2018 − 12 − 20 = 1986.

You can learn more about setting the seed by looking at the documentation:

?set.seed

In the exercises, we may ask you to set the seed to assure that the results you obtain are exactly what we expect them to be. Important note on seeds in R 3.5 versus R 3.6 and later

When R updated to version 3.6 in early 2019, the default method for setting the seed changed. This means that exercises, videos, textbook excerpts and other code you encounter online may yield a different result based on your version of R.

[][If you are running R 3.6 or later, you can revert to the original seed setting behavior by adding the argument sample.kind=“Rounding”. For example:]

set.seed(1) set.seed(1, sample.kind=“Rounding”) # will make R 3.6 generate a seed as in R 3.5

Using the sample.kind=“Rounding” argument will generate a message:

non-uniform ‘Rounding’ sampler used

This is not a warning or a cause for alarm - it is a confirmation that R is using the alternate seed generation method, and you should expect to receive this message in your console.

If you use R 3.6 or later, you should always use the second form of set.seed() in this course series (outside of DataCamp assignments). Failure to do so may result in an otherwise correct answer being rejected by the grader. In most cases where a seed is required, you will be reminded of this fact.

set.seed(1986, sample.kind="Rounding")
## Warning in set.seed(1986, sample.kind = "Rounding"): non-uniform 'Rounding'
## sampler used

Using the mean Function for Probability

An important application of the mean() function

[][In R, applying the mean() function to a logical vector returns the proportion of elements that are TRUE]. It is very common to use the mean() function in this way to calculate probabilities and we will do so throughout the course.

Suppose you have the vector beads from a previous video:

beads <- rep(c(“red”, “blue”), times = c(2,3)) beads [1] “red” “red” “blue” “blue” “blue”

To find the probability of drawing a blue bead at random, you can run:

mean(beads == “blue”) [1] 0.6

This code is broken down into steps inside R. First, R evaluates the logical statement beads == “blue”, which generates the vector:

FALSE FALSE TRUE TRUE TRUE

When the mean function is applied, R coerces the logical values to numeric values, changing TRUE to 1 and FALSE to 0:

0 0 1 1 1

The mean of the zeros and ones thus gives the proportion of TRUE values. As we have learned and will continue to see, probabilities are directly related to the proportion of events that satisfy a requirement.

Probability Distributions

[][Defining a distribution for categorical outcomes is relatively straight forward]. We simply assign a probability to each category. In cases that can be thought of as beads in an urn, for each bead type, the proportion defines the distribution. Another example comes from polling. If you’re are randomly calling likely voters from a population that has 44% Democrat, 44% Republican, 10% undecided, and 2% green, these proportions define the probability for each group. For this example, the probability distribution is simply these four proportions.

Again, categorical data makes it easy to define probability distributions. However, later in applications that are more common in data science, we will learn about probability distributions for continuous variables. In this case, it’ll get a little bit more complex. But for now, we’re going to stick to discrete probabilities before we move on.

[][Textbook link]

This video corresponds to the textbook section on probability distributions. https://rafalab.github.io/dsbook/probability.html#discrete-probability-distributions

[][Key points]

The probability distribution for a variable describes the probability of observing each possible outcome.
For discrete categorical variables, the probability distribution is defined by the proportions for each group.

for each bead type, the proportion defines the distribution

categorical data makes it easy to define probability distribution

( A discrete probability distribution counts occurrences that have countable or finite outcomes. This is in contrast to a continuous distribution, where outcomes can fall anywhere on a continuum. Common examples of discrete distribution include the binomial, Poisson, and Bernoulli distributions. )

Independence

We say that two events are independent if the outcome of one does not affect the other. This classic example are coin tosses. Every time we toss a fair coin, the probability of seeing heads is one half, regardless of what previous tosses have revealed. The same is true when we pick beads from an urn, with replacement. In the example we saw earlier, the probability of red was 0.40, regardless of previous draws. Many examples of events that are not independent come from card games. When we deal the first card, the probability of getting, say a King, is 1 in 13. This is because there are 13 possibilities. You can get an ace, a two, a three, a four, et cetera, 10, Jack, Queen, or King. Now, if we deal a King for the first card, and I don’t replace it, then the probability of getting a King in the second card is less, because there are only three Kings left. The probability is 3 out of not 52, because we already dealt one card, but out of 51. These events are, therefore, not independent.

[][The first outcome affects the second]. To see an extreme case of non-independent events, consider an example of drawing five beads at random, without replacement, from an urn. Three are blue, two are red. I’m going to generate data like this using the sample() function and assign it to x. You can’t see the outcomes. Now, if I ask you to guess the color of the first bead, what do you guess? Since there’s more blue beads, there’s actually a 0.6 chance of seeing blue. That’s probably what you guess. But now I’m going to show you the outcomes of the other four. The second, third, fourth, and fifth outcomes you can see here. You can see that the three blue beads have already come out. This affects the probability of the first. They are not independent. So would you still guess blue? Of course not. Now you know that the probability of red is 1.

These events are not independent. The probabilities change once you see the other outcomes. When events are not independent, conditional probabilities are useful and necessary to make correct calculations. We already saw an example of a conditional probability. We computed the probability that a second dealt card is a King, given that the first was a King. In probability, we use the following notation. We use this dash like this as a shorthand for given that or conditional on, these are synonyms. Note that, [][when two events, say A and B, are independent, we have the following equation. The probability of A given B is equal to the probability of A]. It doesn’t matter what B is. The probability A is unchanged. This is the mathematical way of saying it. And in fact, this can be considered the mathematical definition of independence.

All right now, if we want to know the probability of two events, say A and B, occurring, we can use the multiplication rule. So the probability of A and B is equal to the probability of A multiplied by the probability of B, given that A already happened. Let’s use blackjack as an example. In blackjack, you get assigned to random cards, without replacement. Then you can ask for more. The goal is to get closer to 21 than the dealer, without going over. Face cards are worth 10 points, so is the 10 card, that’s worth 10 points too. And aces are worth either 11 or 1. So if you get an ace and a face card, you win automatically.

So, in blackjack, to calculate the chances of getting 21 in the following way, first we get an ace. And then we get a face card or a 10. We compute the probability of the first being an ace. And then multiply by the probability of a face card or a 10, given that the first card was an ace. The calculation is 1 over 13 chance of getting an ace, times chance of getting a card with value 10, given that we already saw an ace, which is 16 out of 51. We’ve already taken one card out. This is approximately 2%. The multiplicative rule also applies to more than two events. We can use induction to expand for more than two. So the probability of A and B and C is equal to the probability of A times our probability of B, given that A happen, times the probability of C, that A and B happen.

When we have independent events, the multiplication rule becomes simpler. We simply multiply of three probabilities. But we have to be very careful when we use the multiplicative rule in practice. We’re assuming independence. And this can result in very different and incorrect probability calculations when we don’t actually have independence. This can have dire consequences. For example, in a trial, if an expert doesn’t really know the multiplication rule and how to use it. So let’s use an example. This is loosely based on something that actually happened. Imagine a court case in which the suspect was described to have a mustache and a beard. And the prosecution brings in an expert to argue that because 1 in 10 men have beards, and 1 in 5 men has mustaches, using the multiplication rule, this means that only 2% of men have both beards and mustaches, 1/10 times 1/5. 2% is a pretty unlikely event. However, to multiply like this, we need to assume independence. And in this case, it’s clearly not true. The conditional probability of a man having a mustache, conditional on them having a beard, is quite high. It’s about 95%. So the correct calculation actually gives us a much higher probability. It’s 9%, so there’s definitely reasonable doubt.

[][Textbook link]

This video corresponds to the textbook section on independence, conditional probability and the multiplication rule. https://rafalab.github.io/dsbook/probability.html#independence

[][Key points]

Conditional probabilities compute the probability that an event occurs given information about dependent events. For example, the probability of drawing a second king given that the first draw is a king is:

[][ Pr(Card 2 is kind | Card 1 is king) = 3/51]

[][ If two events A and B are independent, Pr(A|B) = Pr(A)] . To determine the probability of multiple events occurring, we use the multiplication rule.

Equations

The multiplication rule for independent events is:

[][ Pr(A and B and C) = Pr(A) x Pr(B) x Pr(c)]

The multiplication rule for dependent events considers the conditional probability of both events occurring:

[][ Pr(A and B) = Pr(A) x Pr(B|A)]

We can expand the multiplication rule for dependent events to more than 2 events:

[][ Pr(A and B and C) = Pr(A) x Pr(B|A) x Pr(C| A and B)]

with replacement

The first outcome affects the second

not independent events are without replacement card games.png

compute the probability that the second dealt card is king, given that the first was king

so the probability of a and b is equal to the probability of a multiplied by the probability of b given that a already happened.png

assume independence, not true at all.png

Question from last video about beard and mustaches?

question posted 2 days ago by john_hhu2020

Sorry I don’t get it, I thought it was 95%, since the instructor mentioned below in the video:

Pr(mustache | beard) = 0.95

I don’t know how does this comes out (this answer or the answer on the book, since it mentioned this: “1/10×95/100=0.095” under this hypothesis: “Say the conditional probability of a man having a mustache conditional on him having a beard is .95”). Say if we applies the multiplicative rule here:

Pr(m and B) = Pr(m) x Pr(b|m)

and since we have 10 sample, Pr(m) = 1/5, Pr(b) = 1/10, then what is the probability of Pr(b|m)? And whats the difference between Pr(b and m) and Pr(b|m), as I cant image the situation of these.

The question is: in this case, what is the difference between Pr(b and m) and Pr(b|m) ??? This post is visible to everyone. 0 responses

john_hhu2020

less than a minute ago

=================================================================================================================================

I see, so the conditionally probability means a situation change: both Numerator and Denominator was changed due to the first event have happened. Thus the Pr(mustache | beard) must be given, and only then we can calculate the Pr(mustache and beard), and this Pr(mustache and beard) means the probability of guy met both conditions in the first condition - the Numerator and Denominator haven’t changed. Anyone willing to help please write something, especially the instructor

Assessment: Introduction to Discrete Probability

Assessment due Jun 15, 2022 10:43 AWST

Probability of cyan

1/1 point (graded)

One ball will be drawn at random from a box containing: 3 cyan balls, 5 magenta balls, and 7 yellow balls. What is the probability that the ball will be cyan? correct

Loading You have used 1 of 5 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button. Correct (1/1 point)

Probability of not cyan

1/1 point (graded)

One ball will be drawn at random from a box containing: 3 cyan balls, 5 magenta balls, and 7 yellow balls. What is the probability that the ball will not be cyan? correct

Loading You have used 1 of 5 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button. Correct (1/1 point)

Sampling without replacement

1/1 point (graded)

Instead of taking just one draw, consider taking two draws. You take the second draw without returning the first draw to the box. We call this sampling without replacement. What is the probability that the first draw is cyan and that the second draw is not cyan?

Provide at least 3 significant digits. correct

Loading You have used 1 of 5 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button. Correct (1/1 point)

Sampling with replacement

1/1 point (graded)

Now repeat the experiment, but this time, after taking the first draw and recording the color, return it back to the box and shake the box. We call this sampling with replacement. What is the probability that the first draw is cyan and that the second draw is not cyan? correct

Loading You have used 1 of 5 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button. Correct (1/1 point)

Have a question about these assessments? Search the discussion forum BEFORE posting below.

Some reminders:

Please be specific in the title and body of your post regarding which question you're asking about to facilitate answering your question.
Posting snippets of code is okay, but posting full code solutions is not.
If you do post snippets of code, please format it as code for readability. If you're not sure how to do this, there are instructions in a pinned post in the discussion forum.

Discussion: Assessment: Introduction to discrete probability’ Topic: Section 1 / Assessment: Introduction to discrete probability

a box containing: 3 cyan balls, 5 magenta balls, and 7 yellow balls.

What is the probability that the first draw is cyan and that the second draw is not cyan?

Pr(A) Cyan

Pr(B) not Cyan

Pr(A and B) = Pr(A) x Pr(B|A) = 3/15 x 12/14 = 1/5 x 6/7 = 6/35

3/15 x 12/15 1/5 x 4/5 4/25

Introduction to DataCamp

DataCamp

You are about the take the first DataCamp assessment. In this course we will be using the DataCamp platform for some assessments. DataCamp provides an R console and and a script editor right here on your browser. Here we give a brief DataCamp tutorial. If you are already familiar with DataCamp you can skip this section and proceed to the next section

To start a DataCamp assessment, you will click on the button that says [][Click here to start the assessment], which looks like this: Click here to start the assessment picture of start the assessment button. You will see a button like this one in the next section: [][Assessment: Introduction to Discrete Probability].

The DataCamp interface has four panels. They are:

The Information Panel: General information about the assessment.
The Instructions Panel: Exercise instructions. The multiple choice questions appear here when applicable.
The Editor: Here is where you type and edit your answers in the form of an R script. Example code also appears here. The editor also includes reminders of the instructions.  Note that # denotes comments. These are not run as code, instead, they tell others what your code is about! 
R console: This is where R commands get executed. You can send commands from the editor to the console but you can also type in commands directly to test out code.

Here is a screenshot of what DataCamp looks like:

Image of DataCamp Platform

There are two ways to send commands from the editor to the console:

  1. If you hit the Submit Answer button, the entire code in the editor gets executed and your answer is evaluated. Remember, after you click Submit Answer in an assessment, your code will be evaluated. If you do not take the hint, you get unlimited tries.

  2. If your cursor is on the editor and you hit command-return on a Mac or control-return on Windows, that line gets executed in the console. You do not submit an answer when you do this. This is a good way to test your script before you submit.

Tip: DataCamp suggests useful keyboard shortcuts after most exercises.

After submit answer on the platform

DataCamp Assessment: Introduction to Discrete Probability

Assessment due Jun 15, 2022 10:43 AWST

This assessment covers the basics of discrete probability. There are two parts to this assessment: the first part is a set of questions on the edX platform, and the second part is a set of coding questions on the DataCamp platform.

In this assessment, you will learn about the fundamentals of discrete probability through looking at examples of sampling from an urn with and without replacement.

By clicking OK, you agree to DataCamp’s privacy policy: https://www.datacamp.com/privacy-policy. Note that you might need to disable your pop-up blocker, or allow “www.datacamp.com” in your pop-up blocker allowed list. When you have completed the exercises, return to edX to continue your learning.

Assessment: Introduction to discrete probability (External resource) (4.5 points possible) By clicking OK, you agree to DataCamp’s privacy policy: https://www.datacamp.com/privacy-policy. https://courses.edx.org/courses/course-v1:HarvardX+PH125.3x+1T2022/xblock/block-v1:HarvardX+PH125.3x+1T2022+type@lti_consumer+block@f8d6dedea9284f2bb67b368dc05d0a38/handler/lti_launch_handler You must be logged in to DataCamp to view your lab scores. To log in, simply click on one of the launch links above (even if you’re not planning to work on a lab right now, but just want to view your scores). Then, refresh this page to view your scores.

Have a question about this assessment? Search the discussion forum to see if someone else has asked or answered your question BEFORE posting below.

Some reminders:

Please be specific in the title and body of your post regarding which question you're asking about to facilitate answering your question.
Posting snippets of code is okay, but posting full code solutions is not.
If you do post snippets of code, please format it as code for readability. If you're not sure how to do this, there are instructions in a pinned post in the general discussion forum.

Discussion: DataCamp Assessment: Introduction to discrete probability Topic: Section 1 / DataCamp Assessment: Introduction to discrete probability

Exercise 1. Probability of cyan - generalized

In the edX exercises for this section, we calculated some probabilities by hand. Now we’ll calculate those probabilities using R.

One ball will be drawn at random from a box containing: 3 cyan balls, 5 magenta balls, and 7 yellow balls.

What is the probability that the ball will be cyan? Instructions 70 XP

Define a variable p as the probability of choosing a cyan ball from the box.
Print the value of p.

Hint

Calculate the proportion of balls in the box that are cyan and assign that value to the variable p.
To print the contents of a variable, write the variable name in a new line of code.
cyan <- 3
magenta <- 5
yellow <- 7

# Assign a variable `p` as the probability of choosing a cyan ball from the box
#p <- rep(c("cyan", "magenta", "yellow"), times=c(3, 5, 7))
p <- cyan/(cyan + magenta + yellow)

# Print the variable `p` to the console
p
## [1] 0.2

Exercise 2. Probability of not cyan - generalized

We defined the variable p as the probability of choosing a cyan ball from a box containing: 3 cyan balls, 5 magenta balls, and 7 yellow balls.

What is the probability that the ball you draw from the box will NOT be cyan? Instructions 100 XP

Using the probability of choosing a cyan ball, p, calculate the probability of choosing any other ball.
# `p` is defined as the probability of choosing a cyan ball from a box containing: 3 cyan balls, 5 magenta balls, and 7 yellow balls.
# Using variable `p`, calculate the probability of choosing any ball that is not cyan from the box

1-p
## [1] 0.8

Exercise 3. Sampling without replacement - generalized

Instead of taking just one draw, consider taking two draws. You take the second draw without returning the first draw to the box. We call this sampling without replacement.

What is the probability that the first draw is cyan and that the second draw is not cyan? Instructions 100 XP

Calculate the conditional probability p_2 of choosing a ball that is not cyan after one cyan ball has been removed from the box.
Calculate the joint probability of both choosing a cyan ball on the first draw and a ball that is not cyan on the second draw using p_1 and p_2.
cyan <- 3
magenta <- 5
yellow <- 7

# The variable `p_1` is the probability of choosing a cyan ball from the box on the first draw.
p_1 <- cyan / (cyan + magenta + yellow)

# Assign a variable `p_2` as the probability of not choosing a cyan ball on the second draw without replacement.

# Calculate the probability that the first draw is cyan and the second draw is not cyan using `p_1` and `p_2`.



# The variable `p_1` is the probability of choosing a cyan ball from the box on the first draw.
p_1 <- cyan / (cyan + magenta + yellow)
p_1
## [1] 0.2
# Assign a variable `p_2` as the probability of not choosing a cyan ball on the second draw without replacement.
p_2 <- (magenta + yellow)/(cyan + magenta + yellow - 1)
p_2
## [1] 0.8571429
# Calculate the probability that the first draw is cyan and the second draw is not cyan using `p_1` and `p_2`.
p_1 * p_2
## [1] 0.1714286

Exercise 4. Sampling with replacement - generalized

Now repeat the experiment, but this time, after taking the first draw and recording the color, return it back to the box and shake the box. We call this sampling with replacement.

What is the probability that the first draw is cyan and that the second draw is not cyan? Instructions 100 XP

Calculate the probability p_2 of choosing a ball that is not cyan on the second draw, with replacement.
Next, use p_1 and p_2 to calculate the probability of choosing a cyan ball on the first draw and a ball that is not cyan on the second draw (after replacing the first ball).
cyan <- 3
magenta <- 5
yellow <- 7

# The variable 'p_1' is the probability of choosing a cyan ball from the box on the first draw.
p_1 <- cyan / (cyan + magenta + yellow)

# Assign a variable 'p_2' as the probability of not choosing a cyan ball on the second draw with replacement.
p_2 <- 1- p_1

# Calculate the probability that the first draw is cyan and the second draw is not cyan using `p_1` and `p_2`.
p_1 * p_2
## [1] 0.16
# Solution =====================================================================================================================
cyan <- 3
magenta <- 5
yellow <- 7

# The variable 'p_1' is the probability of choosing a cyan ball from the box on the first draw.
p_1 <- cyan / (cyan + magenta + yellow)

# Assign a variable 'p_2' as the probability of not choosing a cyan ball on the second draw with replacement.
p_2 <- 1 - (cyan) / (cyan + magenta + yellow)

# Calculate the probability that the first draw is cyan and the second draw is not cyan using `p_1` and `p_2`.
p_1 * p_2
## [1] 0.16

End of Assessment: Introduction to Discrete Probability

This is the end of the programming assignment for this section. Please DO NOT click through to additional assessments from this page. Please DO answer the question on this page. If you do click through, your scores may NOT be recorded.

Click on “Awesome” to get the “points” for this question and then return to the course on edX.

You can close this window and return to Data Science: Probability. Answer the question 50XP Possible Answers

Awesome
press
1
Nope
press
2

Course / Section 1: Discrete Probability / 1.2 Combinations and Permutations

Combinations and Permutations

In our very first example, we imagine an urn with 5 beads–3 blue, 2 red. To review, to compute the probability distribution of 1 draw, we simply listed out all the possibilities– there were 5–and then for each event, we counted how many of these possibilities were associated with that event. So for example, for the blue beads the probability is 0.6. For more complicated examples, however, these computations are not necessarily straightforward. [][For example, what does the probability that if I draw 5 cards without replacement, I get all cards of the same suit, what is called a flush in poker?]

Discrete probability teaches us how to make these computations using mathematics. Here we focus on how to use R code. So we’re going to use card games as examples. So let’s start by constructing a deck of cards using R. For this, we will use the function [][expand.grid()] and the function [][Paste()]. We use Paste to create strings by joining smaller strings. For example, if we have the number and the suit for a card, in 2 different variables we can create the card name using Paste like this. It also works on pairs of vectors. It performs the operation element-wise. So if we type this line of code, we get the following result. The function expand.grid gives us all the combinations of 2 lists ([][the outcome of expand.grid() function is a data.frame, be careful with this]). So for example, if you have blue and black pants and white, gray, and plaid shirt, all your combinations can be computed using the expand.grid function like this. You can see all 6 combinations.

So here’s how we generate a deck of cards. We define the four suits, we define the 13 numbers, and then we create the deck using expand.grid() and then pasting together the 2 columns that expand.grid() creates. Now that we have a deck constructed, we can now start answering questions about probability. Let’s start by doing something simple. Let’s double-check that the probability of a king in the first card is 1 in 13 with R code. We simply [][compute the proportion of possible outcomes that satisfy our condition]. So we create a vector that contains the four ways we can get a king. That’s going to be the kings variable. And then we simply check what proportion of the deck is one of these cards and we get the answer that we expect–0.076 dot dot dot, which is 1 in 13.

Now, ******how about the conditional probability of the second card being a king, given that the first was a king?****** Earlier we deduced that if 1 king is already out, then there’s 51 left. So the probability is 3 in 51. But let’s confirm by listing out all possible outcomes. To do this, we’re going to use [][the combinations() and permutations() functions that are available from the gtools package]. The permutations function computes for any list of size n all the different ways we can select R items. So here’s an example–here all the ways we can choose 2 numbers from the list 1, 2, 3, 4, 5. Notice that the order matters with the permutations() function. So 3, 1 is different than 1, 3, So it appears in our permutations. Also notice that 1, 1; 2, 2; and 3, 3 don’t appear, because once we pick a number, it can’t appear again (no replacement). Optionally for this function permutations, we can add a vector. So for example, if you want to see 5 random 7-digit phone numbers out of all possible phone numbers, you could type code like this. Here we’re defining a vector of digits that goes from 0 to 9 rather than 1 through 10. So these four lines of code generate all phone numbers, picks 5 at random, and then shows them to you.

To compute all possible ways that we can choose 2 cards when the order matters, we simply type the following piece of code. [][Here we use permutations() function. There’s 52 cards, we’re going to choose 2, and we’re going to select them out of the vector that includes our card names, which we called deck earlier]. This is going to be a matrix with 2 dimensions, 2 columns, and in this case, it’s going to have 2,652 rows (possibilities). Those are all the permutations. Now, we’re going to define the first card and the second card by grabbing the first and second columns using this simple piece of code. And now we can, for example, check how many cases have a first card that is a king–that’s 204. [][And now to find the conditional probability, we ask what fraction of these 204 have also a king in the second card]. So this case we type the following piece of code. We add all the cases that have king in the first, king in the second, and divide by the cases that have a king in the first.
# ======================================== Read it, Read it, Read it ================================================================================

And now we get the answer 0.058 dot dot dot, which is exactly 3 out of 51, which we had already deduced. Note that the code we just saw is equivalent to this piece of code where we compute the proportions instead of the totals. And this also gives us the answer that we want, 3 out of 51. This is an R version of the multiplication rule, which tells us the probability of B, given A, is equal to proportion of A and B, or the probability of A and B, divided by the proportion of A or the probability of A. [][Now, what if the order does not matter?] For example, in blackjack, if you get an ace and a face card or a 10, it’s called a natural 21, and you win automatically. If we want to compute the probability of this happening, we want to enumerate the combinations, not permutations, since the order doesn’t matter. So if we get an A and a king, king and an A, it’s still a 21. We don’t want to count that twice. So notice the difference between the permutations functions, which lists all permutations, and the combination function, where order does not matter.

This means that 2, 1 doesn’t appear because 1, 2 already appeared. Similarly, 3, 1 and 3, 2 don’t appear. So to compute the probability of a natural 21 in blackjack, we can do this. We can define a vector that includes all the aces, a vector that includes all the face cards, then we generate all the combinations of picking 2 cards out of 52, and then we simply count. [][How often do we get aces and a face card?] And we get the answer 0.048 dot, dot, dot. Now, notice that in the previous piece of code we assumed that the aces come first. This is only because we know the way that combination generates and enumerates possibilities. But if we want to be safe, we can instead type this code, which considers both possibilities. We get the same answer, and again, this is because we know how combinations works and how it lists the possibilities.

Instead of using combinations to deduce the exact probability of a natural 21, we can also use a Monte Carlo to estimate this probability. In this case, we draw two cards over and over and keep track of how many 21’s we get. We can use the function sample to draw a card without a replacement like this. Here’s 1 hand. We didn’t get a 21 there. And then check if 1 card is an ace and the other is a face card or a 10. Now we simply repeat this over and over and we get a very good approximation–in this case, 0.0488.

[][Textbook link]

Here is a link to the textbook section on combinations and permutations External link. https://rafalab.github.io/dsbook/probability.html#combinations-and-permutations

[][Key points]

paste() joins two strings and inserts a space in between.
expand.grid() gives the combinations of 2 vectors or lists.
permutations(n,r) from the gtools package lists the different ways that r items can be selected from a set of n options when order matters.
combinations(n,r) from the gtools package lists the different ways that r items can be selected from a set of n options when order does not matter.

Code: Introducing paste() and expand.grid()

joining strings with paste

number <- “Three” suit <- “Hearts” paste(number, suit)

joining vectors element-wise with paste

paste(letters[1:5], as.character(1:5))

generating combinations of 2 vectors with expand.grid

expand.grid(pants = c(“blue”, “black”), shirt = c(“white”, “grey”, “plaid”))

Code: Generating a deck of cards

suits <- c(“Diamonds”, “Clubs”, “Hearts”, “Spades”) numbers <- c(“Ace”, “Deuce”, “Three”, “Four”, “Five”, “Six”, “Seven”, “Eight”, “Nine”, “Ten”, “Jack”, “Queen”, “King”) deck <- expand.grid(number = numbers, suit = suits) deck <- paste(deck\(number, deck\)suit)

probability of drawing a king

kings <- paste(“King”, suits) mean(deck %in% kings)

Code: Permutations and combinations

Correction: The code shown does not generate all 7 digit phone numbers because phone numbers can have repeated digits. It generates all possible 7 digit numbers without repeats.

library(gtools) permutations(5,2) # ways to choose 2 numbers in order from 1:5 all_phone_numbers <- permutations(10, 7, v = 0:9) n <- nrow(all_phone_numbers) index <- sample(n, 5) all_phone_numbers[index,]

permutations(3,2) # order matters combinations(3,2) # order does not matter

Code: Probability of drawing a second king given that one king is drawn

hands <- permutations(52,2, v = deck) first_card <- hands[,1] second_card <- hands[,2] sum(first_card %in% kings)

sum(first_card %in% kings & second_card %in% kings) / sum(first_card %in% kings)

Code: Probability of a natural 21 in blackjack

aces <- paste(“Ace”, suits) facecard <- c(“King”, “Queen”, “Jack”, “Ten”) facecard <- expand.grid(number = facecard, suit = suits) facecard <- paste(facecard\(number, facecard\)suit)

hands <- combinations(52, 2, v=deck) # all possible hands

probability of a natural 21 given that the ace is listed first in combinations

mean(hands[,1] %in% aces & hands[,2] %in% facecard)

probability of a natural 21 checking for both ace first and ace second

mean((hands[,1] %in% aces & hands[,2] %in% facecard)|(hands[,2] %in% aces & hands[,1] %in% facecard))

Code: Monte Carlo simulation of natural 21 in blackjack

Note that your exact values will differ because the process is random and the seed is not set.

code for one hand of blackjack

hand <- sample(deck, 2) hand

code for B=10,000 hands of blackjack

B <- 10000 results <- replicate(B, { hand <- sample(deck, 2) (hand[1] %in% aces & hand[2] %in% facecard) | (hand[2] %in% aces & hand[1] %in% facecard) }) mean(results)

number <- "Three"
suit <- "Hearts"

paste(number, suit)
## [1] "Three Hearts"
paste(letters[1:5], as.character(1:5))
## [1] "a 1" "b 2" "c 3" "d 4" "e 5"
expand.grid(pants = c("blue", "black"), shirt = c("white", "gray", "plaid"))
##   pants shirt
## 1  blue white
## 2 black white
## 3  blue  gray
## 4 black  gray
## 5  blue plaid
## 6 black plaid

This is cool, we can image what we want and applying our thought into code, R or Python, no difference

===================================================================================================================================

suits <- c("Diamonds", "Clubs", "Hearts", "Spades")
numbers <- c("Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")


deck <- expand.grid(suit = suits, number = numbers)
length(deck[, 1])
## [1] 52
head(deck)
##       suit number
## 1 Diamonds    Ace
## 2    Clubs    Ace
## 3   Hearts    Ace
## 4   Spades    Ace
## 5 Diamonds  Deuce
## 6    Clubs  Deuce
deck <- paste(deck$suit, deck$number)
length(deck)
## [1] 52
deck
##  [1] "Diamonds Ace"   "Clubs Ace"      "Hearts Ace"     "Spades Ace"    
##  [5] "Diamonds Deuce" "Clubs Deuce"    "Hearts Deuce"   "Spades Deuce"  
##  [9] "Diamonds Three" "Clubs Three"    "Hearts Three"   "Spades Three"  
## [13] "Diamonds Four"  "Clubs Four"     "Hearts Four"    "Spades Four"   
## [17] "Diamonds Five"  "Clubs Five"     "Hearts Five"    "Spades Five"   
## [21] "Diamonds Six"   "Clubs Six"      "Hearts Six"     "Spades Six"    
## [25] "Diamonds Seven" "Clubs Seven"    "Hearts Seven"   "Spades Seven"  
## [29] "Diamonds Eight" "Clubs Eight"    "Hearts Eight"   "Spades Eight"  
## [33] "Diamonds Nine"  "Clubs Nine"     "Hearts Nine"    "Spades Nine"   
## [37] "Diamonds Ten"   "Clubs Ten"      "Hearts Ten"     "Spades Ten"    
## [41] "Diamonds Jack"  "Clubs Jack"     "Hearts Jack"    "Spades Jack"   
## [45] "Diamonds Queen" "Clubs Queen"    "Hearts Queen"   "Spades Queen"  
## [49] "Diamonds King"  "Clubs King"     "Hearts King"    "Spades King"
kings <- paste(suits, "King")

kings
## [1] "Diamonds King" "Clubs King"    "Hearts King"   "Spades King"
mean(deck %in% kings)
## [1] 0.07692308
#mean(length(kings)/length(deck))


# this is how I think calculating probability of second card being king given that the first card is already a king
# ============================================================================================================================
mean((length(kings)-1)/(length(deck)-1))
## [1] 0.05882353
library(gtools)


head(permutations(5, 2))
##      [,1] [,2]
## [1,]    1    2
## [2,]    1    3
## [3,]    1    4
## [4,]    1    5
## [5,]    2    1
## [6,]    2    3
length(permutations(52, 2)[, 1])    # Dont forget after permutation or combinations, you'll have two dimensional df =================================
## [1] 2652
length(combinations(52, 2)[, 1])
## [1] 1326
data.frame(permutations(52, 2, v = deck))
##                  X1             X2
## 1         Clubs Ace    Clubs Deuce
## 2         Clubs Ace    Clubs Eight
## 3         Clubs Ace     Clubs Five
## 4         Clubs Ace     Clubs Four
## 5         Clubs Ace     Clubs Jack
## 6         Clubs Ace     Clubs King
## 7         Clubs Ace     Clubs Nine
## 8         Clubs Ace    Clubs Queen
## 9         Clubs Ace    Clubs Seven
## 10        Clubs Ace      Clubs Six
## 11        Clubs Ace      Clubs Ten
## 12        Clubs Ace    Clubs Three
## 13        Clubs Ace   Diamonds Ace
## 14        Clubs Ace Diamonds Deuce
## 15        Clubs Ace Diamonds Eight
## 16        Clubs Ace  Diamonds Five
## 17        Clubs Ace  Diamonds Four
## 18        Clubs Ace  Diamonds Jack
## 19        Clubs Ace  Diamonds King
## 20        Clubs Ace  Diamonds Nine
## 21        Clubs Ace Diamonds Queen
## 22        Clubs Ace Diamonds Seven
## 23        Clubs Ace   Diamonds Six
## 24        Clubs Ace   Diamonds Ten
## 25        Clubs Ace Diamonds Three
## 26        Clubs Ace     Hearts Ace
## 27        Clubs Ace   Hearts Deuce
## 28        Clubs Ace   Hearts Eight
## 29        Clubs Ace    Hearts Five
## 30        Clubs Ace    Hearts Four
## 31        Clubs Ace    Hearts Jack
## 32        Clubs Ace    Hearts King
## 33        Clubs Ace    Hearts Nine
## 34        Clubs Ace   Hearts Queen
## 35        Clubs Ace   Hearts Seven
## 36        Clubs Ace     Hearts Six
## 37        Clubs Ace     Hearts Ten
## 38        Clubs Ace   Hearts Three
## 39        Clubs Ace     Spades Ace
## 40        Clubs Ace   Spades Deuce
## 41        Clubs Ace   Spades Eight
## 42        Clubs Ace    Spades Five
## 43        Clubs Ace    Spades Four
## 44        Clubs Ace    Spades Jack
## 45        Clubs Ace    Spades King
## 46        Clubs Ace    Spades Nine
## 47        Clubs Ace   Spades Queen
## 48        Clubs Ace   Spades Seven
## 49        Clubs Ace     Spades Six
## 50        Clubs Ace     Spades Ten
## 51        Clubs Ace   Spades Three
## 52      Clubs Deuce      Clubs Ace
## 53      Clubs Deuce    Clubs Eight
## 54      Clubs Deuce     Clubs Five
## 55      Clubs Deuce     Clubs Four
## 56      Clubs Deuce     Clubs Jack
## 57      Clubs Deuce     Clubs King
## 58      Clubs Deuce     Clubs Nine
## 59      Clubs Deuce    Clubs Queen
## 60      Clubs Deuce    Clubs Seven
## 61      Clubs Deuce      Clubs Six
## 62      Clubs Deuce      Clubs Ten
## 63      Clubs Deuce    Clubs Three
## 64      Clubs Deuce   Diamonds Ace
## 65      Clubs Deuce Diamonds Deuce
## 66      Clubs Deuce Diamonds Eight
## 67      Clubs Deuce  Diamonds Five
## 68      Clubs Deuce  Diamonds Four
## 69      Clubs Deuce  Diamonds Jack
## 70      Clubs Deuce  Diamonds King
## 71      Clubs Deuce  Diamonds Nine
## 72      Clubs Deuce Diamonds Queen
## 73      Clubs Deuce Diamonds Seven
## 74      Clubs Deuce   Diamonds Six
## 75      Clubs Deuce   Diamonds Ten
## 76      Clubs Deuce Diamonds Three
## 77      Clubs Deuce     Hearts Ace
## 78      Clubs Deuce   Hearts Deuce
## 79      Clubs Deuce   Hearts Eight
## 80      Clubs Deuce    Hearts Five
## 81      Clubs Deuce    Hearts Four
## 82      Clubs Deuce    Hearts Jack
## 83      Clubs Deuce    Hearts King
## 84      Clubs Deuce    Hearts Nine
## 85      Clubs Deuce   Hearts Queen
## 86      Clubs Deuce   Hearts Seven
## 87      Clubs Deuce     Hearts Six
## 88      Clubs Deuce     Hearts Ten
## 89      Clubs Deuce   Hearts Three
## 90      Clubs Deuce     Spades Ace
## 91      Clubs Deuce   Spades Deuce
## 92      Clubs Deuce   Spades Eight
## 93      Clubs Deuce    Spades Five
## 94      Clubs Deuce    Spades Four
## 95      Clubs Deuce    Spades Jack
## 96      Clubs Deuce    Spades King
## 97      Clubs Deuce    Spades Nine
## 98      Clubs Deuce   Spades Queen
## 99      Clubs Deuce   Spades Seven
## 100     Clubs Deuce     Spades Six
## 101     Clubs Deuce     Spades Ten
## 102     Clubs Deuce   Spades Three
## 103     Clubs Eight      Clubs Ace
## 104     Clubs Eight    Clubs Deuce
## 105     Clubs Eight     Clubs Five
## 106     Clubs Eight     Clubs Four
## 107     Clubs Eight     Clubs Jack
## 108     Clubs Eight     Clubs King
## 109     Clubs Eight     Clubs Nine
## 110     Clubs Eight    Clubs Queen
## 111     Clubs Eight    Clubs Seven
## 112     Clubs Eight      Clubs Six
## 113     Clubs Eight      Clubs Ten
## 114     Clubs Eight    Clubs Three
## 115     Clubs Eight   Diamonds Ace
## 116     Clubs Eight Diamonds Deuce
## 117     Clubs Eight Diamonds Eight
## 118     Clubs Eight  Diamonds Five
## 119     Clubs Eight  Diamonds Four
## 120     Clubs Eight  Diamonds Jack
## 121     Clubs Eight  Diamonds King
## 122     Clubs Eight  Diamonds Nine
## 123     Clubs Eight Diamonds Queen
## 124     Clubs Eight Diamonds Seven
## 125     Clubs Eight   Diamonds Six
## 126     Clubs Eight   Diamonds Ten
## 127     Clubs Eight Diamonds Three
## 128     Clubs Eight     Hearts Ace
## 129     Clubs Eight   Hearts Deuce
## 130     Clubs Eight   Hearts Eight
## 131     Clubs Eight    Hearts Five
## 132     Clubs Eight    Hearts Four
## 133     Clubs Eight    Hearts Jack
## 134     Clubs Eight    Hearts King
## 135     Clubs Eight    Hearts Nine
## 136     Clubs Eight   Hearts Queen
## 137     Clubs Eight   Hearts Seven
## 138     Clubs Eight     Hearts Six
## 139     Clubs Eight     Hearts Ten
## 140     Clubs Eight   Hearts Three
## 141     Clubs Eight     Spades Ace
## 142     Clubs Eight   Spades Deuce
## 143     Clubs Eight   Spades Eight
## 144     Clubs Eight    Spades Five
## 145     Clubs Eight    Spades Four
## 146     Clubs Eight    Spades Jack
## 147     Clubs Eight    Spades King
## 148     Clubs Eight    Spades Nine
## 149     Clubs Eight   Spades Queen
## 150     Clubs Eight   Spades Seven
## 151     Clubs Eight     Spades Six
## 152     Clubs Eight     Spades Ten
## 153     Clubs Eight   Spades Three
## 154      Clubs Five      Clubs Ace
## 155      Clubs Five    Clubs Deuce
## 156      Clubs Five    Clubs Eight
## 157      Clubs Five     Clubs Four
## 158      Clubs Five     Clubs Jack
## 159      Clubs Five     Clubs King
## 160      Clubs Five     Clubs Nine
## 161      Clubs Five    Clubs Queen
## 162      Clubs Five    Clubs Seven
## 163      Clubs Five      Clubs Six
## 164      Clubs Five      Clubs Ten
## 165      Clubs Five    Clubs Three
## 166      Clubs Five   Diamonds Ace
## 167      Clubs Five Diamonds Deuce
## 168      Clubs Five Diamonds Eight
## 169      Clubs Five  Diamonds Five
## 170      Clubs Five  Diamonds Four
## 171      Clubs Five  Diamonds Jack
## 172      Clubs Five  Diamonds King
## 173      Clubs Five  Diamonds Nine
## 174      Clubs Five Diamonds Queen
## 175      Clubs Five Diamonds Seven
## 176      Clubs Five   Diamonds Six
## 177      Clubs Five   Diamonds Ten
## 178      Clubs Five Diamonds Three
## 179      Clubs Five     Hearts Ace
## 180      Clubs Five   Hearts Deuce
## 181      Clubs Five   Hearts Eight
## 182      Clubs Five    Hearts Five
## 183      Clubs Five    Hearts Four
## 184      Clubs Five    Hearts Jack
## 185      Clubs Five    Hearts King
## 186      Clubs Five    Hearts Nine
## 187      Clubs Five   Hearts Queen
## 188      Clubs Five   Hearts Seven
## 189      Clubs Five     Hearts Six
## 190      Clubs Five     Hearts Ten
## 191      Clubs Five   Hearts Three
## 192      Clubs Five     Spades Ace
## 193      Clubs Five   Spades Deuce
## 194      Clubs Five   Spades Eight
## 195      Clubs Five    Spades Five
## 196      Clubs Five    Spades Four
## 197      Clubs Five    Spades Jack
## 198      Clubs Five    Spades King
## 199      Clubs Five    Spades Nine
## 200      Clubs Five   Spades Queen
## 201      Clubs Five   Spades Seven
## 202      Clubs Five     Spades Six
## 203      Clubs Five     Spades Ten
## 204      Clubs Five   Spades Three
## 205      Clubs Four      Clubs Ace
## 206      Clubs Four    Clubs Deuce
## 207      Clubs Four    Clubs Eight
## 208      Clubs Four     Clubs Five
## 209      Clubs Four     Clubs Jack
## 210      Clubs Four     Clubs King
## 211      Clubs Four     Clubs Nine
## 212      Clubs Four    Clubs Queen
## 213      Clubs Four    Clubs Seven
## 214      Clubs Four      Clubs Six
## 215      Clubs Four      Clubs Ten
## 216      Clubs Four    Clubs Three
## 217      Clubs Four   Diamonds Ace
## 218      Clubs Four Diamonds Deuce
## 219      Clubs Four Diamonds Eight
## 220      Clubs Four  Diamonds Five
## 221      Clubs Four  Diamonds Four
## 222      Clubs Four  Diamonds Jack
## 223      Clubs Four  Diamonds King
## 224      Clubs Four  Diamonds Nine
## 225      Clubs Four Diamonds Queen
## 226      Clubs Four Diamonds Seven
## 227      Clubs Four   Diamonds Six
## 228      Clubs Four   Diamonds Ten
## 229      Clubs Four Diamonds Three
## 230      Clubs Four     Hearts Ace
## 231      Clubs Four   Hearts Deuce
## 232      Clubs Four   Hearts Eight
## 233      Clubs Four    Hearts Five
## 234      Clubs Four    Hearts Four
## 235      Clubs Four    Hearts Jack
## 236      Clubs Four    Hearts King
## 237      Clubs Four    Hearts Nine
## 238      Clubs Four   Hearts Queen
## 239      Clubs Four   Hearts Seven
## 240      Clubs Four     Hearts Six
## 241      Clubs Four     Hearts Ten
## 242      Clubs Four   Hearts Three
## 243      Clubs Four     Spades Ace
## 244      Clubs Four   Spades Deuce
## 245      Clubs Four   Spades Eight
## 246      Clubs Four    Spades Five
## 247      Clubs Four    Spades Four
## 248      Clubs Four    Spades Jack
## 249      Clubs Four    Spades King
## 250      Clubs Four    Spades Nine
## 251      Clubs Four   Spades Queen
## 252      Clubs Four   Spades Seven
## 253      Clubs Four     Spades Six
## 254      Clubs Four     Spades Ten
## 255      Clubs Four   Spades Three
## 256      Clubs Jack      Clubs Ace
## 257      Clubs Jack    Clubs Deuce
## 258      Clubs Jack    Clubs Eight
## 259      Clubs Jack     Clubs Five
## 260      Clubs Jack     Clubs Four
## 261      Clubs Jack     Clubs King
## 262      Clubs Jack     Clubs Nine
## 263      Clubs Jack    Clubs Queen
## 264      Clubs Jack    Clubs Seven
## 265      Clubs Jack      Clubs Six
## 266      Clubs Jack      Clubs Ten
## 267      Clubs Jack    Clubs Three
## 268      Clubs Jack   Diamonds Ace
## 269      Clubs Jack Diamonds Deuce
## 270      Clubs Jack Diamonds Eight
## 271      Clubs Jack  Diamonds Five
## 272      Clubs Jack  Diamonds Four
## 273      Clubs Jack  Diamonds Jack
## 274      Clubs Jack  Diamonds King
## 275      Clubs Jack  Diamonds Nine
## 276      Clubs Jack Diamonds Queen
## 277      Clubs Jack Diamonds Seven
## 278      Clubs Jack   Diamonds Six
## 279      Clubs Jack   Diamonds Ten
## 280      Clubs Jack Diamonds Three
## 281      Clubs Jack     Hearts Ace
## 282      Clubs Jack   Hearts Deuce
## 283      Clubs Jack   Hearts Eight
## 284      Clubs Jack    Hearts Five
## 285      Clubs Jack    Hearts Four
## 286      Clubs Jack    Hearts Jack
## 287      Clubs Jack    Hearts King
## 288      Clubs Jack    Hearts Nine
## 289      Clubs Jack   Hearts Queen
## 290      Clubs Jack   Hearts Seven
## 291      Clubs Jack     Hearts Six
## 292      Clubs Jack     Hearts Ten
## 293      Clubs Jack   Hearts Three
## 294      Clubs Jack     Spades Ace
## 295      Clubs Jack   Spades Deuce
## 296      Clubs Jack   Spades Eight
## 297      Clubs Jack    Spades Five
## 298      Clubs Jack    Spades Four
## 299      Clubs Jack    Spades Jack
## 300      Clubs Jack    Spades King
## 301      Clubs Jack    Spades Nine
## 302      Clubs Jack   Spades Queen
## 303      Clubs Jack   Spades Seven
## 304      Clubs Jack     Spades Six
## 305      Clubs Jack     Spades Ten
## 306      Clubs Jack   Spades Three
## 307      Clubs King      Clubs Ace
## 308      Clubs King    Clubs Deuce
## 309      Clubs King    Clubs Eight
## 310      Clubs King     Clubs Five
## 311      Clubs King     Clubs Four
## 312      Clubs King     Clubs Jack
## 313      Clubs King     Clubs Nine
## 314      Clubs King    Clubs Queen
## 315      Clubs King    Clubs Seven
## 316      Clubs King      Clubs Six
## 317      Clubs King      Clubs Ten
## 318      Clubs King    Clubs Three
## 319      Clubs King   Diamonds Ace
## 320      Clubs King Diamonds Deuce
## 321      Clubs King Diamonds Eight
## 322      Clubs King  Diamonds Five
## 323      Clubs King  Diamonds Four
## 324      Clubs King  Diamonds Jack
## 325      Clubs King  Diamonds King
## 326      Clubs King  Diamonds Nine
## 327      Clubs King Diamonds Queen
## 328      Clubs King Diamonds Seven
## 329      Clubs King   Diamonds Six
## 330      Clubs King   Diamonds Ten
## 331      Clubs King Diamonds Three
## 332      Clubs King     Hearts Ace
## 333      Clubs King   Hearts Deuce
## 334      Clubs King   Hearts Eight
## 335      Clubs King    Hearts Five
## 336      Clubs King    Hearts Four
## 337      Clubs King    Hearts Jack
## 338      Clubs King    Hearts King
## 339      Clubs King    Hearts Nine
## 340      Clubs King   Hearts Queen
## 341      Clubs King   Hearts Seven
## 342      Clubs King     Hearts Six
## 343      Clubs King     Hearts Ten
## 344      Clubs King   Hearts Three
## 345      Clubs King     Spades Ace
## 346      Clubs King   Spades Deuce
## 347      Clubs King   Spades Eight
## 348      Clubs King    Spades Five
## 349      Clubs King    Spades Four
## 350      Clubs King    Spades Jack
## 351      Clubs King    Spades King
## 352      Clubs King    Spades Nine
## 353      Clubs King   Spades Queen
## 354      Clubs King   Spades Seven
## 355      Clubs King     Spades Six
## 356      Clubs King     Spades Ten
## 357      Clubs King   Spades Three
## 358      Clubs Nine      Clubs Ace
## 359      Clubs Nine    Clubs Deuce
## 360      Clubs Nine    Clubs Eight
## 361      Clubs Nine     Clubs Five
## 362      Clubs Nine     Clubs Four
## 363      Clubs Nine     Clubs Jack
## 364      Clubs Nine     Clubs King
## 365      Clubs Nine    Clubs Queen
## 366      Clubs Nine    Clubs Seven
## 367      Clubs Nine      Clubs Six
## 368      Clubs Nine      Clubs Ten
## 369      Clubs Nine    Clubs Three
## 370      Clubs Nine   Diamonds Ace
## 371      Clubs Nine Diamonds Deuce
## 372      Clubs Nine Diamonds Eight
## 373      Clubs Nine  Diamonds Five
## 374      Clubs Nine  Diamonds Four
## 375      Clubs Nine  Diamonds Jack
## 376      Clubs Nine  Diamonds King
## 377      Clubs Nine  Diamonds Nine
## 378      Clubs Nine Diamonds Queen
## 379      Clubs Nine Diamonds Seven
## 380      Clubs Nine   Diamonds Six
## 381      Clubs Nine   Diamonds Ten
## 382      Clubs Nine Diamonds Three
## 383      Clubs Nine     Hearts Ace
## 384      Clubs Nine   Hearts Deuce
## 385      Clubs Nine   Hearts Eight
## 386      Clubs Nine    Hearts Five
## 387      Clubs Nine    Hearts Four
## 388      Clubs Nine    Hearts Jack
## 389      Clubs Nine    Hearts King
## 390      Clubs Nine    Hearts Nine
## 391      Clubs Nine   Hearts Queen
## 392      Clubs Nine   Hearts Seven
## 393      Clubs Nine     Hearts Six
## 394      Clubs Nine     Hearts Ten
## 395      Clubs Nine   Hearts Three
## 396      Clubs Nine     Spades Ace
## 397      Clubs Nine   Spades Deuce
## 398      Clubs Nine   Spades Eight
## 399      Clubs Nine    Spades Five
## 400      Clubs Nine    Spades Four
## 401      Clubs Nine    Spades Jack
## 402      Clubs Nine    Spades King
## 403      Clubs Nine    Spades Nine
## 404      Clubs Nine   Spades Queen
## 405      Clubs Nine   Spades Seven
## 406      Clubs Nine     Spades Six
## 407      Clubs Nine     Spades Ten
## 408      Clubs Nine   Spades Three
## 409     Clubs Queen      Clubs Ace
## 410     Clubs Queen    Clubs Deuce
## 411     Clubs Queen    Clubs Eight
## 412     Clubs Queen     Clubs Five
## 413     Clubs Queen     Clubs Four
## 414     Clubs Queen     Clubs Jack
## 415     Clubs Queen     Clubs King
## 416     Clubs Queen     Clubs Nine
## 417     Clubs Queen    Clubs Seven
## 418     Clubs Queen      Clubs Six
## 419     Clubs Queen      Clubs Ten
## 420     Clubs Queen    Clubs Three
## 421     Clubs Queen   Diamonds Ace
## 422     Clubs Queen Diamonds Deuce
## 423     Clubs Queen Diamonds Eight
## 424     Clubs Queen  Diamonds Five
## 425     Clubs Queen  Diamonds Four
## 426     Clubs Queen  Diamonds Jack
## 427     Clubs Queen  Diamonds King
## 428     Clubs Queen  Diamonds Nine
## 429     Clubs Queen Diamonds Queen
## 430     Clubs Queen Diamonds Seven
## 431     Clubs Queen   Diamonds Six
## 432     Clubs Queen   Diamonds Ten
## 433     Clubs Queen Diamonds Three
## 434     Clubs Queen     Hearts Ace
## 435     Clubs Queen   Hearts Deuce
## 436     Clubs Queen   Hearts Eight
## 437     Clubs Queen    Hearts Five
## 438     Clubs Queen    Hearts Four
## 439     Clubs Queen    Hearts Jack
## 440     Clubs Queen    Hearts King
## 441     Clubs Queen    Hearts Nine
## 442     Clubs Queen   Hearts Queen
## 443     Clubs Queen   Hearts Seven
## 444     Clubs Queen     Hearts Six
## 445     Clubs Queen     Hearts Ten
## 446     Clubs Queen   Hearts Three
## 447     Clubs Queen     Spades Ace
## 448     Clubs Queen   Spades Deuce
## 449     Clubs Queen   Spades Eight
## 450     Clubs Queen    Spades Five
## 451     Clubs Queen    Spades Four
## 452     Clubs Queen    Spades Jack
## 453     Clubs Queen    Spades King
## 454     Clubs Queen    Spades Nine
## 455     Clubs Queen   Spades Queen
## 456     Clubs Queen   Spades Seven
## 457     Clubs Queen     Spades Six
## 458     Clubs Queen     Spades Ten
## 459     Clubs Queen   Spades Three
## 460     Clubs Seven      Clubs Ace
## 461     Clubs Seven    Clubs Deuce
## 462     Clubs Seven    Clubs Eight
## 463     Clubs Seven     Clubs Five
## 464     Clubs Seven     Clubs Four
## 465     Clubs Seven     Clubs Jack
## 466     Clubs Seven     Clubs King
## 467     Clubs Seven     Clubs Nine
## 468     Clubs Seven    Clubs Queen
## 469     Clubs Seven      Clubs Six
## 470     Clubs Seven      Clubs Ten
## 471     Clubs Seven    Clubs Three
## 472     Clubs Seven   Diamonds Ace
## 473     Clubs Seven Diamonds Deuce
## 474     Clubs Seven Diamonds Eight
## 475     Clubs Seven  Diamonds Five
## 476     Clubs Seven  Diamonds Four
## 477     Clubs Seven  Diamonds Jack
## 478     Clubs Seven  Diamonds King
## 479     Clubs Seven  Diamonds Nine
## 480     Clubs Seven Diamonds Queen
## 481     Clubs Seven Diamonds Seven
## 482     Clubs Seven   Diamonds Six
## 483     Clubs Seven   Diamonds Ten
## 484     Clubs Seven Diamonds Three
## 485     Clubs Seven     Hearts Ace
## 486     Clubs Seven   Hearts Deuce
## 487     Clubs Seven   Hearts Eight
## 488     Clubs Seven    Hearts Five
## 489     Clubs Seven    Hearts Four
## 490     Clubs Seven    Hearts Jack
## 491     Clubs Seven    Hearts King
## 492     Clubs Seven    Hearts Nine
## 493     Clubs Seven   Hearts Queen
## 494     Clubs Seven   Hearts Seven
## 495     Clubs Seven     Hearts Six
## 496     Clubs Seven     Hearts Ten
## 497     Clubs Seven   Hearts Three
## 498     Clubs Seven     Spades Ace
## 499     Clubs Seven   Spades Deuce
## 500     Clubs Seven   Spades Eight
## 501     Clubs Seven    Spades Five
## 502     Clubs Seven    Spades Four
## 503     Clubs Seven    Spades Jack
## 504     Clubs Seven    Spades King
## 505     Clubs Seven    Spades Nine
## 506     Clubs Seven   Spades Queen
## 507     Clubs Seven   Spades Seven
## 508     Clubs Seven     Spades Six
## 509     Clubs Seven     Spades Ten
## 510     Clubs Seven   Spades Three
## 511       Clubs Six      Clubs Ace
## 512       Clubs Six    Clubs Deuce
## 513       Clubs Six    Clubs Eight
## 514       Clubs Six     Clubs Five
## 515       Clubs Six     Clubs Four
## 516       Clubs Six     Clubs Jack
## 517       Clubs Six     Clubs King
## 518       Clubs Six     Clubs Nine
## 519       Clubs Six    Clubs Queen
## 520       Clubs Six    Clubs Seven
## 521       Clubs Six      Clubs Ten
## 522       Clubs Six    Clubs Three
## 523       Clubs Six   Diamonds Ace
## 524       Clubs Six Diamonds Deuce
## 525       Clubs Six Diamonds Eight
## 526       Clubs Six  Diamonds Five
## 527       Clubs Six  Diamonds Four
## 528       Clubs Six  Diamonds Jack
## 529       Clubs Six  Diamonds King
## 530       Clubs Six  Diamonds Nine
## 531       Clubs Six Diamonds Queen
## 532       Clubs Six Diamonds Seven
## 533       Clubs Six   Diamonds Six
## 534       Clubs Six   Diamonds Ten
## 535       Clubs Six Diamonds Three
## 536       Clubs Six     Hearts Ace
## 537       Clubs Six   Hearts Deuce
## 538       Clubs Six   Hearts Eight
## 539       Clubs Six    Hearts Five
## 540       Clubs Six    Hearts Four
## 541       Clubs Six    Hearts Jack
## 542       Clubs Six    Hearts King
## 543       Clubs Six    Hearts Nine
## 544       Clubs Six   Hearts Queen
## 545       Clubs Six   Hearts Seven
## 546       Clubs Six     Hearts Six
## 547       Clubs Six     Hearts Ten
## 548       Clubs Six   Hearts Three
## 549       Clubs Six     Spades Ace
## 550       Clubs Six   Spades Deuce
## 551       Clubs Six   Spades Eight
## 552       Clubs Six    Spades Five
## 553       Clubs Six    Spades Four
## 554       Clubs Six    Spades Jack
## 555       Clubs Six    Spades King
## 556       Clubs Six    Spades Nine
## 557       Clubs Six   Spades Queen
## 558       Clubs Six   Spades Seven
## 559       Clubs Six     Spades Six
## 560       Clubs Six     Spades Ten
## 561       Clubs Six   Spades Three
## 562       Clubs Ten      Clubs Ace
## 563       Clubs Ten    Clubs Deuce
## 564       Clubs Ten    Clubs Eight
## 565       Clubs Ten     Clubs Five
## 566       Clubs Ten     Clubs Four
## 567       Clubs Ten     Clubs Jack
## 568       Clubs Ten     Clubs King
## 569       Clubs Ten     Clubs Nine
## 570       Clubs Ten    Clubs Queen
## 571       Clubs Ten    Clubs Seven
## 572       Clubs Ten      Clubs Six
## 573       Clubs Ten    Clubs Three
## 574       Clubs Ten   Diamonds Ace
## 575       Clubs Ten Diamonds Deuce
## 576       Clubs Ten Diamonds Eight
## 577       Clubs Ten  Diamonds Five
## 578       Clubs Ten  Diamonds Four
## 579       Clubs Ten  Diamonds Jack
## 580       Clubs Ten  Diamonds King
## 581       Clubs Ten  Diamonds Nine
## 582       Clubs Ten Diamonds Queen
## 583       Clubs Ten Diamonds Seven
## 584       Clubs Ten   Diamonds Six
## 585       Clubs Ten   Diamonds Ten
## 586       Clubs Ten Diamonds Three
## 587       Clubs Ten     Hearts Ace
## 588       Clubs Ten   Hearts Deuce
## 589       Clubs Ten   Hearts Eight
## 590       Clubs Ten    Hearts Five
## 591       Clubs Ten    Hearts Four
## 592       Clubs Ten    Hearts Jack
## 593       Clubs Ten    Hearts King
## 594       Clubs Ten    Hearts Nine
## 595       Clubs Ten   Hearts Queen
## 596       Clubs Ten   Hearts Seven
## 597       Clubs Ten     Hearts Six
## 598       Clubs Ten     Hearts Ten
## 599       Clubs Ten   Hearts Three
## 600       Clubs Ten     Spades Ace
## 601       Clubs Ten   Spades Deuce
## 602       Clubs Ten   Spades Eight
## 603       Clubs Ten    Spades Five
## 604       Clubs Ten    Spades Four
## 605       Clubs Ten    Spades Jack
## 606       Clubs Ten    Spades King
## 607       Clubs Ten    Spades Nine
## 608       Clubs Ten   Spades Queen
## 609       Clubs Ten   Spades Seven
## 610       Clubs Ten     Spades Six
## 611       Clubs Ten     Spades Ten
## 612       Clubs Ten   Spades Three
## 613     Clubs Three      Clubs Ace
## 614     Clubs Three    Clubs Deuce
## 615     Clubs Three    Clubs Eight
## 616     Clubs Three     Clubs Five
## 617     Clubs Three     Clubs Four
## 618     Clubs Three     Clubs Jack
## 619     Clubs Three     Clubs King
## 620     Clubs Three     Clubs Nine
## 621     Clubs Three    Clubs Queen
## 622     Clubs Three    Clubs Seven
## 623     Clubs Three      Clubs Six
## 624     Clubs Three      Clubs Ten
## 625     Clubs Three   Diamonds Ace
## 626     Clubs Three Diamonds Deuce
## 627     Clubs Three Diamonds Eight
## 628     Clubs Three  Diamonds Five
## 629     Clubs Three  Diamonds Four
## 630     Clubs Three  Diamonds Jack
## 631     Clubs Three  Diamonds King
## 632     Clubs Three  Diamonds Nine
## 633     Clubs Three Diamonds Queen
## 634     Clubs Three Diamonds Seven
## 635     Clubs Three   Diamonds Six
## 636     Clubs Three   Diamonds Ten
## 637     Clubs Three Diamonds Three
## 638     Clubs Three     Hearts Ace
## 639     Clubs Three   Hearts Deuce
## 640     Clubs Three   Hearts Eight
## 641     Clubs Three    Hearts Five
## 642     Clubs Three    Hearts Four
## 643     Clubs Three    Hearts Jack
## 644     Clubs Three    Hearts King
## 645     Clubs Three    Hearts Nine
## 646     Clubs Three   Hearts Queen
## 647     Clubs Three   Hearts Seven
## 648     Clubs Three     Hearts Six
## 649     Clubs Three     Hearts Ten
## 650     Clubs Three   Hearts Three
## 651     Clubs Three     Spades Ace
## 652     Clubs Three   Spades Deuce
## 653     Clubs Three   Spades Eight
## 654     Clubs Three    Spades Five
## 655     Clubs Three    Spades Four
## 656     Clubs Three    Spades Jack
## 657     Clubs Three    Spades King
## 658     Clubs Three    Spades Nine
## 659     Clubs Three   Spades Queen
## 660     Clubs Three   Spades Seven
## 661     Clubs Three     Spades Six
## 662     Clubs Three     Spades Ten
## 663     Clubs Three   Spades Three
## 664    Diamonds Ace      Clubs Ace
## 665    Diamonds Ace    Clubs Deuce
## 666    Diamonds Ace    Clubs Eight
## 667    Diamonds Ace     Clubs Five
## 668    Diamonds Ace     Clubs Four
## 669    Diamonds Ace     Clubs Jack
## 670    Diamonds Ace     Clubs King
## 671    Diamonds Ace     Clubs Nine
## 672    Diamonds Ace    Clubs Queen
## 673    Diamonds Ace    Clubs Seven
## 674    Diamonds Ace      Clubs Six
## 675    Diamonds Ace      Clubs Ten
## 676    Diamonds Ace    Clubs Three
## 677    Diamonds Ace Diamonds Deuce
## 678    Diamonds Ace Diamonds Eight
## 679    Diamonds Ace  Diamonds Five
## 680    Diamonds Ace  Diamonds Four
## 681    Diamonds Ace  Diamonds Jack
## 682    Diamonds Ace  Diamonds King
## 683    Diamonds Ace  Diamonds Nine
## 684    Diamonds Ace Diamonds Queen
## 685    Diamonds Ace Diamonds Seven
## 686    Diamonds Ace   Diamonds Six
## 687    Diamonds Ace   Diamonds Ten
## 688    Diamonds Ace Diamonds Three
## 689    Diamonds Ace     Hearts Ace
## 690    Diamonds Ace   Hearts Deuce
## 691    Diamonds Ace   Hearts Eight
## 692    Diamonds Ace    Hearts Five
## 693    Diamonds Ace    Hearts Four
## 694    Diamonds Ace    Hearts Jack
## 695    Diamonds Ace    Hearts King
## 696    Diamonds Ace    Hearts Nine
## 697    Diamonds Ace   Hearts Queen
## 698    Diamonds Ace   Hearts Seven
## 699    Diamonds Ace     Hearts Six
## 700    Diamonds Ace     Hearts Ten
## 701    Diamonds Ace   Hearts Three
## 702    Diamonds Ace     Spades Ace
## 703    Diamonds Ace   Spades Deuce
## 704    Diamonds Ace   Spades Eight
## 705    Diamonds Ace    Spades Five
## 706    Diamonds Ace    Spades Four
## 707    Diamonds Ace    Spades Jack
## 708    Diamonds Ace    Spades King
## 709    Diamonds Ace    Spades Nine
## 710    Diamonds Ace   Spades Queen
## 711    Diamonds Ace   Spades Seven
## 712    Diamonds Ace     Spades Six
## 713    Diamonds Ace     Spades Ten
## 714    Diamonds Ace   Spades Three
## 715  Diamonds Deuce      Clubs Ace
## 716  Diamonds Deuce    Clubs Deuce
## 717  Diamonds Deuce    Clubs Eight
## 718  Diamonds Deuce     Clubs Five
## 719  Diamonds Deuce     Clubs Four
## 720  Diamonds Deuce     Clubs Jack
## 721  Diamonds Deuce     Clubs King
## 722  Diamonds Deuce     Clubs Nine
## 723  Diamonds Deuce    Clubs Queen
## 724  Diamonds Deuce    Clubs Seven
## 725  Diamonds Deuce      Clubs Six
## 726  Diamonds Deuce      Clubs Ten
## 727  Diamonds Deuce    Clubs Three
## 728  Diamonds Deuce   Diamonds Ace
## 729  Diamonds Deuce Diamonds Eight
## 730  Diamonds Deuce  Diamonds Five
## 731  Diamonds Deuce  Diamonds Four
## 732  Diamonds Deuce  Diamonds Jack
## 733  Diamonds Deuce  Diamonds King
## 734  Diamonds Deuce  Diamonds Nine
## 735  Diamonds Deuce Diamonds Queen
## 736  Diamonds Deuce Diamonds Seven
## 737  Diamonds Deuce   Diamonds Six
## 738  Diamonds Deuce   Diamonds Ten
## 739  Diamonds Deuce Diamonds Three
## 740  Diamonds Deuce     Hearts Ace
## 741  Diamonds Deuce   Hearts Deuce
## 742  Diamonds Deuce   Hearts Eight
## 743  Diamonds Deuce    Hearts Five
## 744  Diamonds Deuce    Hearts Four
## 745  Diamonds Deuce    Hearts Jack
## 746  Diamonds Deuce    Hearts King
## 747  Diamonds Deuce    Hearts Nine
## 748  Diamonds Deuce   Hearts Queen
## 749  Diamonds Deuce   Hearts Seven
## 750  Diamonds Deuce     Hearts Six
## 751  Diamonds Deuce     Hearts Ten
## 752  Diamonds Deuce   Hearts Three
## 753  Diamonds Deuce     Spades Ace
## 754  Diamonds Deuce   Spades Deuce
## 755  Diamonds Deuce   Spades Eight
## 756  Diamonds Deuce    Spades Five
## 757  Diamonds Deuce    Spades Four
## 758  Diamonds Deuce    Spades Jack
## 759  Diamonds Deuce    Spades King
## 760  Diamonds Deuce    Spades Nine
## 761  Diamonds Deuce   Spades Queen
## 762  Diamonds Deuce   Spades Seven
## 763  Diamonds Deuce     Spades Six
## 764  Diamonds Deuce     Spades Ten
## 765  Diamonds Deuce   Spades Three
## 766  Diamonds Eight      Clubs Ace
## 767  Diamonds Eight    Clubs Deuce
## 768  Diamonds Eight    Clubs Eight
## 769  Diamonds Eight     Clubs Five
## 770  Diamonds Eight     Clubs Four
## 771  Diamonds Eight     Clubs Jack
## 772  Diamonds Eight     Clubs King
## 773  Diamonds Eight     Clubs Nine
## 774  Diamonds Eight    Clubs Queen
## 775  Diamonds Eight    Clubs Seven
## 776  Diamonds Eight      Clubs Six
## 777  Diamonds Eight      Clubs Ten
## 778  Diamonds Eight    Clubs Three
## 779  Diamonds Eight   Diamonds Ace
## 780  Diamonds Eight Diamonds Deuce
## 781  Diamonds Eight  Diamonds Five
## 782  Diamonds Eight  Diamonds Four
## 783  Diamonds Eight  Diamonds Jack
## 784  Diamonds Eight  Diamonds King
## 785  Diamonds Eight  Diamonds Nine
## 786  Diamonds Eight Diamonds Queen
## 787  Diamonds Eight Diamonds Seven
## 788  Diamonds Eight   Diamonds Six
## 789  Diamonds Eight   Diamonds Ten
## 790  Diamonds Eight Diamonds Three
## 791  Diamonds Eight     Hearts Ace
## 792  Diamonds Eight   Hearts Deuce
## 793  Diamonds Eight   Hearts Eight
## 794  Diamonds Eight    Hearts Five
## 795  Diamonds Eight    Hearts Four
## 796  Diamonds Eight    Hearts Jack
## 797  Diamonds Eight    Hearts King
## 798  Diamonds Eight    Hearts Nine
## 799  Diamonds Eight   Hearts Queen
## 800  Diamonds Eight   Hearts Seven
## 801  Diamonds Eight     Hearts Six
## 802  Diamonds Eight     Hearts Ten
## 803  Diamonds Eight   Hearts Three
## 804  Diamonds Eight     Spades Ace
## 805  Diamonds Eight   Spades Deuce
## 806  Diamonds Eight   Spades Eight
## 807  Diamonds Eight    Spades Five
## 808  Diamonds Eight    Spades Four
## 809  Diamonds Eight    Spades Jack
## 810  Diamonds Eight    Spades King
## 811  Diamonds Eight    Spades Nine
## 812  Diamonds Eight   Spades Queen
## 813  Diamonds Eight   Spades Seven
## 814  Diamonds Eight     Spades Six
## 815  Diamonds Eight     Spades Ten
## 816  Diamonds Eight   Spades Three
## 817   Diamonds Five      Clubs Ace
## 818   Diamonds Five    Clubs Deuce
## 819   Diamonds Five    Clubs Eight
## 820   Diamonds Five     Clubs Five
## 821   Diamonds Five     Clubs Four
## 822   Diamonds Five     Clubs Jack
## 823   Diamonds Five     Clubs King
## 824   Diamonds Five     Clubs Nine
## 825   Diamonds Five    Clubs Queen
## 826   Diamonds Five    Clubs Seven
## 827   Diamonds Five      Clubs Six
## 828   Diamonds Five      Clubs Ten
## 829   Diamonds Five    Clubs Three
## 830   Diamonds Five   Diamonds Ace
## 831   Diamonds Five Diamonds Deuce
## 832   Diamonds Five Diamonds Eight
## 833   Diamonds Five  Diamonds Four
## 834   Diamonds Five  Diamonds Jack
## 835   Diamonds Five  Diamonds King
## 836   Diamonds Five  Diamonds Nine
## 837   Diamonds Five Diamonds Queen
## 838   Diamonds Five Diamonds Seven
## 839   Diamonds Five   Diamonds Six
## 840   Diamonds Five   Diamonds Ten
## 841   Diamonds Five Diamonds Three
## 842   Diamonds Five     Hearts Ace
## 843   Diamonds Five   Hearts Deuce
## 844   Diamonds Five   Hearts Eight
## 845   Diamonds Five    Hearts Five
## 846   Diamonds Five    Hearts Four
## 847   Diamonds Five    Hearts Jack
## 848   Diamonds Five    Hearts King
## 849   Diamonds Five    Hearts Nine
## 850   Diamonds Five   Hearts Queen
## 851   Diamonds Five   Hearts Seven
## 852   Diamonds Five     Hearts Six
## 853   Diamonds Five     Hearts Ten
## 854   Diamonds Five   Hearts Three
## 855   Diamonds Five     Spades Ace
## 856   Diamonds Five   Spades Deuce
## 857   Diamonds Five   Spades Eight
## 858   Diamonds Five    Spades Five
## 859   Diamonds Five    Spades Four
## 860   Diamonds Five    Spades Jack
## 861   Diamonds Five    Spades King
## 862   Diamonds Five    Spades Nine
## 863   Diamonds Five   Spades Queen
## 864   Diamonds Five   Spades Seven
## 865   Diamonds Five     Spades Six
## 866   Diamonds Five     Spades Ten
## 867   Diamonds Five   Spades Three
## 868   Diamonds Four      Clubs Ace
## 869   Diamonds Four    Clubs Deuce
## 870   Diamonds Four    Clubs Eight
## 871   Diamonds Four     Clubs Five
## 872   Diamonds Four     Clubs Four
## 873   Diamonds Four     Clubs Jack
## 874   Diamonds Four     Clubs King
## 875   Diamonds Four     Clubs Nine
## 876   Diamonds Four    Clubs Queen
## 877   Diamonds Four    Clubs Seven
## 878   Diamonds Four      Clubs Six
## 879   Diamonds Four      Clubs Ten
## 880   Diamonds Four    Clubs Three
## 881   Diamonds Four   Diamonds Ace
## 882   Diamonds Four Diamonds Deuce
## 883   Diamonds Four Diamonds Eight
## 884   Diamonds Four  Diamonds Five
## 885   Diamonds Four  Diamonds Jack
## 886   Diamonds Four  Diamonds King
## 887   Diamonds Four  Diamonds Nine
## 888   Diamonds Four Diamonds Queen
## 889   Diamonds Four Diamonds Seven
## 890   Diamonds Four   Diamonds Six
## 891   Diamonds Four   Diamonds Ten
## 892   Diamonds Four Diamonds Three
## 893   Diamonds Four     Hearts Ace
## 894   Diamonds Four   Hearts Deuce
## 895   Diamonds Four   Hearts Eight
## 896   Diamonds Four    Hearts Five
## 897   Diamonds Four    Hearts Four
## 898   Diamonds Four    Hearts Jack
## 899   Diamonds Four    Hearts King
## 900   Diamonds Four    Hearts Nine
## 901   Diamonds Four   Hearts Queen
## 902   Diamonds Four   Hearts Seven
## 903   Diamonds Four     Hearts Six
## 904   Diamonds Four     Hearts Ten
## 905   Diamonds Four   Hearts Three
## 906   Diamonds Four     Spades Ace
## 907   Diamonds Four   Spades Deuce
## 908   Diamonds Four   Spades Eight
## 909   Diamonds Four    Spades Five
## 910   Diamonds Four    Spades Four
## 911   Diamonds Four    Spades Jack
## 912   Diamonds Four    Spades King
## 913   Diamonds Four    Spades Nine
## 914   Diamonds Four   Spades Queen
## 915   Diamonds Four   Spades Seven
## 916   Diamonds Four     Spades Six
## 917   Diamonds Four     Spades Ten
## 918   Diamonds Four   Spades Three
## 919   Diamonds Jack      Clubs Ace
## 920   Diamonds Jack    Clubs Deuce
## 921   Diamonds Jack    Clubs Eight
## 922   Diamonds Jack     Clubs Five
## 923   Diamonds Jack     Clubs Four
## 924   Diamonds Jack     Clubs Jack
## 925   Diamonds Jack     Clubs King
## 926   Diamonds Jack     Clubs Nine
## 927   Diamonds Jack    Clubs Queen
## 928   Diamonds Jack    Clubs Seven
## 929   Diamonds Jack      Clubs Six
## 930   Diamonds Jack      Clubs Ten
## 931   Diamonds Jack    Clubs Three
## 932   Diamonds Jack   Diamonds Ace
## 933   Diamonds Jack Diamonds Deuce
## 934   Diamonds Jack Diamonds Eight
## 935   Diamonds Jack  Diamonds Five
## 936   Diamonds Jack  Diamonds Four
## 937   Diamonds Jack  Diamonds King
## 938   Diamonds Jack  Diamonds Nine
## 939   Diamonds Jack Diamonds Queen
## 940   Diamonds Jack Diamonds Seven
## 941   Diamonds Jack   Diamonds Six
## 942   Diamonds Jack   Diamonds Ten
## 943   Diamonds Jack Diamonds Three
## 944   Diamonds Jack     Hearts Ace
## 945   Diamonds Jack   Hearts Deuce
## 946   Diamonds Jack   Hearts Eight
## 947   Diamonds Jack    Hearts Five
## 948   Diamonds Jack    Hearts Four
## 949   Diamonds Jack    Hearts Jack
## 950   Diamonds Jack    Hearts King
## 951   Diamonds Jack    Hearts Nine
## 952   Diamonds Jack   Hearts Queen
## 953   Diamonds Jack   Hearts Seven
## 954   Diamonds Jack     Hearts Six
## 955   Diamonds Jack     Hearts Ten
## 956   Diamonds Jack   Hearts Three
## 957   Diamonds Jack     Spades Ace
## 958   Diamonds Jack   Spades Deuce
## 959   Diamonds Jack   Spades Eight
## 960   Diamonds Jack    Spades Five
## 961   Diamonds Jack    Spades Four
## 962   Diamonds Jack    Spades Jack
## 963   Diamonds Jack    Spades King
## 964   Diamonds Jack    Spades Nine
## 965   Diamonds Jack   Spades Queen
## 966   Diamonds Jack   Spades Seven
## 967   Diamonds Jack     Spades Six
## 968   Diamonds Jack     Spades Ten
## 969   Diamonds Jack   Spades Three
## 970   Diamonds King      Clubs Ace
## 971   Diamonds King    Clubs Deuce
## 972   Diamonds King    Clubs Eight
## 973   Diamonds King     Clubs Five
## 974   Diamonds King     Clubs Four
## 975   Diamonds King     Clubs Jack
## 976   Diamonds King     Clubs King
## 977   Diamonds King     Clubs Nine
## 978   Diamonds King    Clubs Queen
## 979   Diamonds King    Clubs Seven
## 980   Diamonds King      Clubs Six
## 981   Diamonds King      Clubs Ten
## 982   Diamonds King    Clubs Three
## 983   Diamonds King   Diamonds Ace
## 984   Diamonds King Diamonds Deuce
## 985   Diamonds King Diamonds Eight
## 986   Diamonds King  Diamonds Five
## 987   Diamonds King  Diamonds Four
## 988   Diamonds King  Diamonds Jack
## 989   Diamonds King  Diamonds Nine
## 990   Diamonds King Diamonds Queen
## 991   Diamonds King Diamonds Seven
## 992   Diamonds King   Diamonds Six
## 993   Diamonds King   Diamonds Ten
## 994   Diamonds King Diamonds Three
## 995   Diamonds King     Hearts Ace
## 996   Diamonds King   Hearts Deuce
## 997   Diamonds King   Hearts Eight
## 998   Diamonds King    Hearts Five
## 999   Diamonds King    Hearts Four
## 1000  Diamonds King    Hearts Jack
## 1001  Diamonds King    Hearts King
## 1002  Diamonds King    Hearts Nine
## 1003  Diamonds King   Hearts Queen
## 1004  Diamonds King   Hearts Seven
## 1005  Diamonds King     Hearts Six
## 1006  Diamonds King     Hearts Ten
## 1007  Diamonds King   Hearts Three
## 1008  Diamonds King     Spades Ace
## 1009  Diamonds King   Spades Deuce
## 1010  Diamonds King   Spades Eight
## 1011  Diamonds King    Spades Five
## 1012  Diamonds King    Spades Four
## 1013  Diamonds King    Spades Jack
## 1014  Diamonds King    Spades King
## 1015  Diamonds King    Spades Nine
## 1016  Diamonds King   Spades Queen
## 1017  Diamonds King   Spades Seven
## 1018  Diamonds King     Spades Six
## 1019  Diamonds King     Spades Ten
## 1020  Diamonds King   Spades Three
## 1021  Diamonds Nine      Clubs Ace
## 1022  Diamonds Nine    Clubs Deuce
## 1023  Diamonds Nine    Clubs Eight
## 1024  Diamonds Nine     Clubs Five
## 1025  Diamonds Nine     Clubs Four
## 1026  Diamonds Nine     Clubs Jack
## 1027  Diamonds Nine     Clubs King
## 1028  Diamonds Nine     Clubs Nine
## 1029  Diamonds Nine    Clubs Queen
## 1030  Diamonds Nine    Clubs Seven
## 1031  Diamonds Nine      Clubs Six
## 1032  Diamonds Nine      Clubs Ten
## 1033  Diamonds Nine    Clubs Three
## 1034  Diamonds Nine   Diamonds Ace
## 1035  Diamonds Nine Diamonds Deuce
## 1036  Diamonds Nine Diamonds Eight
## 1037  Diamonds Nine  Diamonds Five
## 1038  Diamonds Nine  Diamonds Four
## 1039  Diamonds Nine  Diamonds Jack
## 1040  Diamonds Nine  Diamonds King
## 1041  Diamonds Nine Diamonds Queen
## 1042  Diamonds Nine Diamonds Seven
## 1043  Diamonds Nine   Diamonds Six
## 1044  Diamonds Nine   Diamonds Ten
## 1045  Diamonds Nine Diamonds Three
## 1046  Diamonds Nine     Hearts Ace
## 1047  Diamonds Nine   Hearts Deuce
## 1048  Diamonds Nine   Hearts Eight
## 1049  Diamonds Nine    Hearts Five
## 1050  Diamonds Nine    Hearts Four
## 1051  Diamonds Nine    Hearts Jack
## 1052  Diamonds Nine    Hearts King
## 1053  Diamonds Nine    Hearts Nine
## 1054  Diamonds Nine   Hearts Queen
## 1055  Diamonds Nine   Hearts Seven
## 1056  Diamonds Nine     Hearts Six
## 1057  Diamonds Nine     Hearts Ten
## 1058  Diamonds Nine   Hearts Three
## 1059  Diamonds Nine     Spades Ace
## 1060  Diamonds Nine   Spades Deuce
## 1061  Diamonds Nine   Spades Eight
## 1062  Diamonds Nine    Spades Five
## 1063  Diamonds Nine    Spades Four
## 1064  Diamonds Nine    Spades Jack
## 1065  Diamonds Nine    Spades King
## 1066  Diamonds Nine    Spades Nine
## 1067  Diamonds Nine   Spades Queen
## 1068  Diamonds Nine   Spades Seven
## 1069  Diamonds Nine     Spades Six
## 1070  Diamonds Nine     Spades Ten
## 1071  Diamonds Nine   Spades Three
## 1072 Diamonds Queen      Clubs Ace
## 1073 Diamonds Queen    Clubs Deuce
## 1074 Diamonds Queen    Clubs Eight
## 1075 Diamonds Queen     Clubs Five
## 1076 Diamonds Queen     Clubs Four
## 1077 Diamonds Queen     Clubs Jack
## 1078 Diamonds Queen     Clubs King
## 1079 Diamonds Queen     Clubs Nine
## 1080 Diamonds Queen    Clubs Queen
## 1081 Diamonds Queen    Clubs Seven
## 1082 Diamonds Queen      Clubs Six
## 1083 Diamonds Queen      Clubs Ten
## 1084 Diamonds Queen    Clubs Three
## 1085 Diamonds Queen   Diamonds Ace
## 1086 Diamonds Queen Diamonds Deuce
## 1087 Diamonds Queen Diamonds Eight
## 1088 Diamonds Queen  Diamonds Five
## 1089 Diamonds Queen  Diamonds Four
## 1090 Diamonds Queen  Diamonds Jack
## 1091 Diamonds Queen  Diamonds King
## 1092 Diamonds Queen  Diamonds Nine
## 1093 Diamonds Queen Diamonds Seven
## 1094 Diamonds Queen   Diamonds Six
## 1095 Diamonds Queen   Diamonds Ten
## 1096 Diamonds Queen Diamonds Three
## 1097 Diamonds Queen     Hearts Ace
## 1098 Diamonds Queen   Hearts Deuce
## 1099 Diamonds Queen   Hearts Eight
## 1100 Diamonds Queen    Hearts Five
## 1101 Diamonds Queen    Hearts Four
## 1102 Diamonds Queen    Hearts Jack
## 1103 Diamonds Queen    Hearts King
## 1104 Diamonds Queen    Hearts Nine
## 1105 Diamonds Queen   Hearts Queen
## 1106 Diamonds Queen   Hearts Seven
## 1107 Diamonds Queen     Hearts Six
## 1108 Diamonds Queen     Hearts Ten
## 1109 Diamonds Queen   Hearts Three
## 1110 Diamonds Queen     Spades Ace
## 1111 Diamonds Queen   Spades Deuce
## 1112 Diamonds Queen   Spades Eight
## 1113 Diamonds Queen    Spades Five
## 1114 Diamonds Queen    Spades Four
## 1115 Diamonds Queen    Spades Jack
## 1116 Diamonds Queen    Spades King
## 1117 Diamonds Queen    Spades Nine
## 1118 Diamonds Queen   Spades Queen
## 1119 Diamonds Queen   Spades Seven
## 1120 Diamonds Queen     Spades Six
## 1121 Diamonds Queen     Spades Ten
## 1122 Diamonds Queen   Spades Three
## 1123 Diamonds Seven      Clubs Ace
## 1124 Diamonds Seven    Clubs Deuce
## 1125 Diamonds Seven    Clubs Eight
## 1126 Diamonds Seven     Clubs Five
## 1127 Diamonds Seven     Clubs Four
## 1128 Diamonds Seven     Clubs Jack
## 1129 Diamonds Seven     Clubs King
## 1130 Diamonds Seven     Clubs Nine
## 1131 Diamonds Seven    Clubs Queen
## 1132 Diamonds Seven    Clubs Seven
## 1133 Diamonds Seven      Clubs Six
## 1134 Diamonds Seven      Clubs Ten
## 1135 Diamonds Seven    Clubs Three
## 1136 Diamonds Seven   Diamonds Ace
## 1137 Diamonds Seven Diamonds Deuce
## 1138 Diamonds Seven Diamonds Eight
## 1139 Diamonds Seven  Diamonds Five
## 1140 Diamonds Seven  Diamonds Four
## 1141 Diamonds Seven  Diamonds Jack
## 1142 Diamonds Seven  Diamonds King
## 1143 Diamonds Seven  Diamonds Nine
## 1144 Diamonds Seven Diamonds Queen
## 1145 Diamonds Seven   Diamonds Six
## 1146 Diamonds Seven   Diamonds Ten
## 1147 Diamonds Seven Diamonds Three
## 1148 Diamonds Seven     Hearts Ace
## 1149 Diamonds Seven   Hearts Deuce
## 1150 Diamonds Seven   Hearts Eight
## 1151 Diamonds Seven    Hearts Five
## 1152 Diamonds Seven    Hearts Four
## 1153 Diamonds Seven    Hearts Jack
## 1154 Diamonds Seven    Hearts King
## 1155 Diamonds Seven    Hearts Nine
## 1156 Diamonds Seven   Hearts Queen
## 1157 Diamonds Seven   Hearts Seven
## 1158 Diamonds Seven     Hearts Six
## 1159 Diamonds Seven     Hearts Ten
## 1160 Diamonds Seven   Hearts Three
## 1161 Diamonds Seven     Spades Ace
## 1162 Diamonds Seven   Spades Deuce
## 1163 Diamonds Seven   Spades Eight
## 1164 Diamonds Seven    Spades Five
## 1165 Diamonds Seven    Spades Four
## 1166 Diamonds Seven    Spades Jack
## 1167 Diamonds Seven    Spades King
## 1168 Diamonds Seven    Spades Nine
## 1169 Diamonds Seven   Spades Queen
## 1170 Diamonds Seven   Spades Seven
## 1171 Diamonds Seven     Spades Six
## 1172 Diamonds Seven     Spades Ten
## 1173 Diamonds Seven   Spades Three
## 1174   Diamonds Six      Clubs Ace
## 1175   Diamonds Six    Clubs Deuce
## 1176   Diamonds Six    Clubs Eight
## 1177   Diamonds Six     Clubs Five
## 1178   Diamonds Six     Clubs Four
## 1179   Diamonds Six     Clubs Jack
## 1180   Diamonds Six     Clubs King
## 1181   Diamonds Six     Clubs Nine
## 1182   Diamonds Six    Clubs Queen
## 1183   Diamonds Six    Clubs Seven
## 1184   Diamonds Six      Clubs Six
## 1185   Diamonds Six      Clubs Ten
## 1186   Diamonds Six    Clubs Three
## 1187   Diamonds Six   Diamonds Ace
## 1188   Diamonds Six Diamonds Deuce
## 1189   Diamonds Six Diamonds Eight
## 1190   Diamonds Six  Diamonds Five
## 1191   Diamonds Six  Diamonds Four
## 1192   Diamonds Six  Diamonds Jack
## 1193   Diamonds Six  Diamonds King
## 1194   Diamonds Six  Diamonds Nine
## 1195   Diamonds Six Diamonds Queen
## 1196   Diamonds Six Diamonds Seven
## 1197   Diamonds Six   Diamonds Ten
## 1198   Diamonds Six Diamonds Three
## 1199   Diamonds Six     Hearts Ace
## 1200   Diamonds Six   Hearts Deuce
## 1201   Diamonds Six   Hearts Eight
## 1202   Diamonds Six    Hearts Five
## 1203   Diamonds Six    Hearts Four
## 1204   Diamonds Six    Hearts Jack
## 1205   Diamonds Six    Hearts King
## 1206   Diamonds Six    Hearts Nine
## 1207   Diamonds Six   Hearts Queen
## 1208   Diamonds Six   Hearts Seven
## 1209   Diamonds Six     Hearts Six
## 1210   Diamonds Six     Hearts Ten
## 1211   Diamonds Six   Hearts Three
## 1212   Diamonds Six     Spades Ace
## 1213   Diamonds Six   Spades Deuce
## 1214   Diamonds Six   Spades Eight
## 1215   Diamonds Six    Spades Five
## 1216   Diamonds Six    Spades Four
## 1217   Diamonds Six    Spades Jack
## 1218   Diamonds Six    Spades King
## 1219   Diamonds Six    Spades Nine
## 1220   Diamonds Six   Spades Queen
## 1221   Diamonds Six   Spades Seven
## 1222   Diamonds Six     Spades Six
## 1223   Diamonds Six     Spades Ten
## 1224   Diamonds Six   Spades Three
## 1225   Diamonds Ten      Clubs Ace
## 1226   Diamonds Ten    Clubs Deuce
## 1227   Diamonds Ten    Clubs Eight
## 1228   Diamonds Ten     Clubs Five
## 1229   Diamonds Ten     Clubs Four
## 1230   Diamonds Ten     Clubs Jack
## 1231   Diamonds Ten     Clubs King
## 1232   Diamonds Ten     Clubs Nine
## 1233   Diamonds Ten    Clubs Queen
## 1234   Diamonds Ten    Clubs Seven
## 1235   Diamonds Ten      Clubs Six
## 1236   Diamonds Ten      Clubs Ten
## 1237   Diamonds Ten    Clubs Three
## 1238   Diamonds Ten   Diamonds Ace
## 1239   Diamonds Ten Diamonds Deuce
## 1240   Diamonds Ten Diamonds Eight
## 1241   Diamonds Ten  Diamonds Five
## 1242   Diamonds Ten  Diamonds Four
## 1243   Diamonds Ten  Diamonds Jack
## 1244   Diamonds Ten  Diamonds King
## 1245   Diamonds Ten  Diamonds Nine
## 1246   Diamonds Ten Diamonds Queen
## 1247   Diamonds Ten Diamonds Seven
## 1248   Diamonds Ten   Diamonds Six
## 1249   Diamonds Ten Diamonds Three
## 1250   Diamonds Ten     Hearts Ace
## 1251   Diamonds Ten   Hearts Deuce
## 1252   Diamonds Ten   Hearts Eight
## 1253   Diamonds Ten    Hearts Five
## 1254   Diamonds Ten    Hearts Four
## 1255   Diamonds Ten    Hearts Jack
## 1256   Diamonds Ten    Hearts King
## 1257   Diamonds Ten    Hearts Nine
## 1258   Diamonds Ten   Hearts Queen
## 1259   Diamonds Ten   Hearts Seven
## 1260   Diamonds Ten     Hearts Six
## 1261   Diamonds Ten     Hearts Ten
## 1262   Diamonds Ten   Hearts Three
## 1263   Diamonds Ten     Spades Ace
## 1264   Diamonds Ten   Spades Deuce
## 1265   Diamonds Ten   Spades Eight
## 1266   Diamonds Ten    Spades Five
## 1267   Diamonds Ten    Spades Four
## 1268   Diamonds Ten    Spades Jack
## 1269   Diamonds Ten    Spades King
## 1270   Diamonds Ten    Spades Nine
## 1271   Diamonds Ten   Spades Queen
## 1272   Diamonds Ten   Spades Seven
## 1273   Diamonds Ten     Spades Six
## 1274   Diamonds Ten     Spades Ten
## 1275   Diamonds Ten   Spades Three
## 1276 Diamonds Three      Clubs Ace
## 1277 Diamonds Three    Clubs Deuce
## 1278 Diamonds Three    Clubs Eight
## 1279 Diamonds Three     Clubs Five
## 1280 Diamonds Three     Clubs Four
## 1281 Diamonds Three     Clubs Jack
## 1282 Diamonds Three     Clubs King
## 1283 Diamonds Three     Clubs Nine
## 1284 Diamonds Three    Clubs Queen
## 1285 Diamonds Three    Clubs Seven
## 1286 Diamonds Three      Clubs Six
## 1287 Diamonds Three      Clubs Ten
## 1288 Diamonds Three    Clubs Three
## 1289 Diamonds Three   Diamonds Ace
## 1290 Diamonds Three Diamonds Deuce
## 1291 Diamonds Three Diamonds Eight
## 1292 Diamonds Three  Diamonds Five
## 1293 Diamonds Three  Diamonds Four
## 1294 Diamonds Three  Diamonds Jack
## 1295 Diamonds Three  Diamonds King
## 1296 Diamonds Three  Diamonds Nine
## 1297 Diamonds Three Diamonds Queen
## 1298 Diamonds Three Diamonds Seven
## 1299 Diamonds Three   Diamonds Six
## 1300 Diamonds Three   Diamonds Ten
## 1301 Diamonds Three     Hearts Ace
## 1302 Diamonds Three   Hearts Deuce
## 1303 Diamonds Three   Hearts Eight
## 1304 Diamonds Three    Hearts Five
## 1305 Diamonds Three    Hearts Four
## 1306 Diamonds Three    Hearts Jack
## 1307 Diamonds Three    Hearts King
## 1308 Diamonds Three    Hearts Nine
## 1309 Diamonds Three   Hearts Queen
## 1310 Diamonds Three   Hearts Seven
## 1311 Diamonds Three     Hearts Six
## 1312 Diamonds Three     Hearts Ten
## 1313 Diamonds Three   Hearts Three
## 1314 Diamonds Three     Spades Ace
## 1315 Diamonds Three   Spades Deuce
## 1316 Diamonds Three   Spades Eight
## 1317 Diamonds Three    Spades Five
## 1318 Diamonds Three    Spades Four
## 1319 Diamonds Three    Spades Jack
## 1320 Diamonds Three    Spades King
## 1321 Diamonds Three    Spades Nine
## 1322 Diamonds Three   Spades Queen
## 1323 Diamonds Three   Spades Seven
## 1324 Diamonds Three     Spades Six
## 1325 Diamonds Three     Spades Ten
## 1326 Diamonds Three   Spades Three
## 1327     Hearts Ace      Clubs Ace
## 1328     Hearts Ace    Clubs Deuce
## 1329     Hearts Ace    Clubs Eight
## 1330     Hearts Ace     Clubs Five
## 1331     Hearts Ace     Clubs Four
## 1332     Hearts Ace     Clubs Jack
## 1333     Hearts Ace     Clubs King
## 1334     Hearts Ace     Clubs Nine
## 1335     Hearts Ace    Clubs Queen
## 1336     Hearts Ace    Clubs Seven
## 1337     Hearts Ace      Clubs Six
## 1338     Hearts Ace      Clubs Ten
## 1339     Hearts Ace    Clubs Three
## 1340     Hearts Ace   Diamonds Ace
## 1341     Hearts Ace Diamonds Deuce
## 1342     Hearts Ace Diamonds Eight
## 1343     Hearts Ace  Diamonds Five
## 1344     Hearts Ace  Diamonds Four
## 1345     Hearts Ace  Diamonds Jack
## 1346     Hearts Ace  Diamonds King
## 1347     Hearts Ace  Diamonds Nine
## 1348     Hearts Ace Diamonds Queen
## 1349     Hearts Ace Diamonds Seven
## 1350     Hearts Ace   Diamonds Six
## 1351     Hearts Ace   Diamonds Ten
## 1352     Hearts Ace Diamonds Three
## 1353     Hearts Ace   Hearts Deuce
## 1354     Hearts Ace   Hearts Eight
## 1355     Hearts Ace    Hearts Five
## 1356     Hearts Ace    Hearts Four
## 1357     Hearts Ace    Hearts Jack
## 1358     Hearts Ace    Hearts King
## 1359     Hearts Ace    Hearts Nine
## 1360     Hearts Ace   Hearts Queen
## 1361     Hearts Ace   Hearts Seven
## 1362     Hearts Ace     Hearts Six
## 1363     Hearts Ace     Hearts Ten
## 1364     Hearts Ace   Hearts Three
## 1365     Hearts Ace     Spades Ace
## 1366     Hearts Ace   Spades Deuce
## 1367     Hearts Ace   Spades Eight
## 1368     Hearts Ace    Spades Five
## 1369     Hearts Ace    Spades Four
## 1370     Hearts Ace    Spades Jack
## 1371     Hearts Ace    Spades King
## 1372     Hearts Ace    Spades Nine
## 1373     Hearts Ace   Spades Queen
## 1374     Hearts Ace   Spades Seven
## 1375     Hearts Ace     Spades Six
## 1376     Hearts Ace     Spades Ten
## 1377     Hearts Ace   Spades Three
## 1378   Hearts Deuce      Clubs Ace
## 1379   Hearts Deuce    Clubs Deuce
## 1380   Hearts Deuce    Clubs Eight
## 1381   Hearts Deuce     Clubs Five
## 1382   Hearts Deuce     Clubs Four
## 1383   Hearts Deuce     Clubs Jack
## 1384   Hearts Deuce     Clubs King
## 1385   Hearts Deuce     Clubs Nine
## 1386   Hearts Deuce    Clubs Queen
## 1387   Hearts Deuce    Clubs Seven
## 1388   Hearts Deuce      Clubs Six
## 1389   Hearts Deuce      Clubs Ten
## 1390   Hearts Deuce    Clubs Three
## 1391   Hearts Deuce   Diamonds Ace
## 1392   Hearts Deuce Diamonds Deuce
## 1393   Hearts Deuce Diamonds Eight
## 1394   Hearts Deuce  Diamonds Five
## 1395   Hearts Deuce  Diamonds Four
## 1396   Hearts Deuce  Diamonds Jack
## 1397   Hearts Deuce  Diamonds King
## 1398   Hearts Deuce  Diamonds Nine
## 1399   Hearts Deuce Diamonds Queen
## 1400   Hearts Deuce Diamonds Seven
## 1401   Hearts Deuce   Diamonds Six
## 1402   Hearts Deuce   Diamonds Ten
## 1403   Hearts Deuce Diamonds Three
## 1404   Hearts Deuce     Hearts Ace
## 1405   Hearts Deuce   Hearts Eight
## 1406   Hearts Deuce    Hearts Five
## 1407   Hearts Deuce    Hearts Four
## 1408   Hearts Deuce    Hearts Jack
## 1409   Hearts Deuce    Hearts King
## 1410   Hearts Deuce    Hearts Nine
## 1411   Hearts Deuce   Hearts Queen
## 1412   Hearts Deuce   Hearts Seven
## 1413   Hearts Deuce     Hearts Six
## 1414   Hearts Deuce     Hearts Ten
## 1415   Hearts Deuce   Hearts Three
## 1416   Hearts Deuce     Spades Ace
## 1417   Hearts Deuce   Spades Deuce
## 1418   Hearts Deuce   Spades Eight
## 1419   Hearts Deuce    Spades Five
## 1420   Hearts Deuce    Spades Four
## 1421   Hearts Deuce    Spades Jack
## 1422   Hearts Deuce    Spades King
## 1423   Hearts Deuce    Spades Nine
## 1424   Hearts Deuce   Spades Queen
## 1425   Hearts Deuce   Spades Seven
## 1426   Hearts Deuce     Spades Six
## 1427   Hearts Deuce     Spades Ten
## 1428   Hearts Deuce   Spades Three
## 1429   Hearts Eight      Clubs Ace
## 1430   Hearts Eight    Clubs Deuce
## 1431   Hearts Eight    Clubs Eight
## 1432   Hearts Eight     Clubs Five
## 1433   Hearts Eight     Clubs Four
## 1434   Hearts Eight     Clubs Jack
## 1435   Hearts Eight     Clubs King
## 1436   Hearts Eight     Clubs Nine
## 1437   Hearts Eight    Clubs Queen
## 1438   Hearts Eight    Clubs Seven
## 1439   Hearts Eight      Clubs Six
## 1440   Hearts Eight      Clubs Ten
## 1441   Hearts Eight    Clubs Three
## 1442   Hearts Eight   Diamonds Ace
## 1443   Hearts Eight Diamonds Deuce
## 1444   Hearts Eight Diamonds Eight
## 1445   Hearts Eight  Diamonds Five
## 1446   Hearts Eight  Diamonds Four
## 1447   Hearts Eight  Diamonds Jack
## 1448   Hearts Eight  Diamonds King
## 1449   Hearts Eight  Diamonds Nine
## 1450   Hearts Eight Diamonds Queen
## 1451   Hearts Eight Diamonds Seven
## 1452   Hearts Eight   Diamonds Six
## 1453   Hearts Eight   Diamonds Ten
## 1454   Hearts Eight Diamonds Three
## 1455   Hearts Eight     Hearts Ace
## 1456   Hearts Eight   Hearts Deuce
## 1457   Hearts Eight    Hearts Five
## 1458   Hearts Eight    Hearts Four
## 1459   Hearts Eight    Hearts Jack
## 1460   Hearts Eight    Hearts King
## 1461   Hearts Eight    Hearts Nine
## 1462   Hearts Eight   Hearts Queen
## 1463   Hearts Eight   Hearts Seven
## 1464   Hearts Eight     Hearts Six
## 1465   Hearts Eight     Hearts Ten
## 1466   Hearts Eight   Hearts Three
## 1467   Hearts Eight     Spades Ace
## 1468   Hearts Eight   Spades Deuce
## 1469   Hearts Eight   Spades Eight
## 1470   Hearts Eight    Spades Five
## 1471   Hearts Eight    Spades Four
## 1472   Hearts Eight    Spades Jack
## 1473   Hearts Eight    Spades King
## 1474   Hearts Eight    Spades Nine
## 1475   Hearts Eight   Spades Queen
## 1476   Hearts Eight   Spades Seven
## 1477   Hearts Eight     Spades Six
## 1478   Hearts Eight     Spades Ten
## 1479   Hearts Eight   Spades Three
## 1480    Hearts Five      Clubs Ace
## 1481    Hearts Five    Clubs Deuce
## 1482    Hearts Five    Clubs Eight
## 1483    Hearts Five     Clubs Five
## 1484    Hearts Five     Clubs Four
## 1485    Hearts Five     Clubs Jack
## 1486    Hearts Five     Clubs King
## 1487    Hearts Five     Clubs Nine
## 1488    Hearts Five    Clubs Queen
## 1489    Hearts Five    Clubs Seven
## 1490    Hearts Five      Clubs Six
## 1491    Hearts Five      Clubs Ten
## 1492    Hearts Five    Clubs Three
## 1493    Hearts Five   Diamonds Ace
## 1494    Hearts Five Diamonds Deuce
## 1495    Hearts Five Diamonds Eight
## 1496    Hearts Five  Diamonds Five
## 1497    Hearts Five  Diamonds Four
## 1498    Hearts Five  Diamonds Jack
## 1499    Hearts Five  Diamonds King
## 1500    Hearts Five  Diamonds Nine
## 1501    Hearts Five Diamonds Queen
## 1502    Hearts Five Diamonds Seven
## 1503    Hearts Five   Diamonds Six
## 1504    Hearts Five   Diamonds Ten
## 1505    Hearts Five Diamonds Three
## 1506    Hearts Five     Hearts Ace
## 1507    Hearts Five   Hearts Deuce
## 1508    Hearts Five   Hearts Eight
## 1509    Hearts Five    Hearts Four
## 1510    Hearts Five    Hearts Jack
## 1511    Hearts Five    Hearts King
## 1512    Hearts Five    Hearts Nine
## 1513    Hearts Five   Hearts Queen
## 1514    Hearts Five   Hearts Seven
## 1515    Hearts Five     Hearts Six
## 1516    Hearts Five     Hearts Ten
## 1517    Hearts Five   Hearts Three
## 1518    Hearts Five     Spades Ace
## 1519    Hearts Five   Spades Deuce
## 1520    Hearts Five   Spades Eight
## 1521    Hearts Five    Spades Five
## 1522    Hearts Five    Spades Four
## 1523    Hearts Five    Spades Jack
## 1524    Hearts Five    Spades King
## 1525    Hearts Five    Spades Nine
## 1526    Hearts Five   Spades Queen
## 1527    Hearts Five   Spades Seven
## 1528    Hearts Five     Spades Six
## 1529    Hearts Five     Spades Ten
## 1530    Hearts Five   Spades Three
## 1531    Hearts Four      Clubs Ace
## 1532    Hearts Four    Clubs Deuce
## 1533    Hearts Four    Clubs Eight
## 1534    Hearts Four     Clubs Five
## 1535    Hearts Four     Clubs Four
## 1536    Hearts Four     Clubs Jack
## 1537    Hearts Four     Clubs King
## 1538    Hearts Four     Clubs Nine
## 1539    Hearts Four    Clubs Queen
## 1540    Hearts Four    Clubs Seven
## 1541    Hearts Four      Clubs Six
## 1542    Hearts Four      Clubs Ten
## 1543    Hearts Four    Clubs Three
## 1544    Hearts Four   Diamonds Ace
## 1545    Hearts Four Diamonds Deuce
## 1546    Hearts Four Diamonds Eight
## 1547    Hearts Four  Diamonds Five
## 1548    Hearts Four  Diamonds Four
## 1549    Hearts Four  Diamonds Jack
## 1550    Hearts Four  Diamonds King
## 1551    Hearts Four  Diamonds Nine
## 1552    Hearts Four Diamonds Queen
## 1553    Hearts Four Diamonds Seven
## 1554    Hearts Four   Diamonds Six
## 1555    Hearts Four   Diamonds Ten
## 1556    Hearts Four Diamonds Three
## 1557    Hearts Four     Hearts Ace
## 1558    Hearts Four   Hearts Deuce
## 1559    Hearts Four   Hearts Eight
## 1560    Hearts Four    Hearts Five
## 1561    Hearts Four    Hearts Jack
## 1562    Hearts Four    Hearts King
## 1563    Hearts Four    Hearts Nine
## 1564    Hearts Four   Hearts Queen
## 1565    Hearts Four   Hearts Seven
## 1566    Hearts Four     Hearts Six
## 1567    Hearts Four     Hearts Ten
## 1568    Hearts Four   Hearts Three
## 1569    Hearts Four     Spades Ace
## 1570    Hearts Four   Spades Deuce
## 1571    Hearts Four   Spades Eight
## 1572    Hearts Four    Spades Five
## 1573    Hearts Four    Spades Four
## 1574    Hearts Four    Spades Jack
## 1575    Hearts Four    Spades King
## 1576    Hearts Four    Spades Nine
## 1577    Hearts Four   Spades Queen
## 1578    Hearts Four   Spades Seven
## 1579    Hearts Four     Spades Six
## 1580    Hearts Four     Spades Ten
## 1581    Hearts Four   Spades Three
## 1582    Hearts Jack      Clubs Ace
## 1583    Hearts Jack    Clubs Deuce
## 1584    Hearts Jack    Clubs Eight
## 1585    Hearts Jack     Clubs Five
## 1586    Hearts Jack     Clubs Four
## 1587    Hearts Jack     Clubs Jack
## 1588    Hearts Jack     Clubs King
## 1589    Hearts Jack     Clubs Nine
## 1590    Hearts Jack    Clubs Queen
## 1591    Hearts Jack    Clubs Seven
## 1592    Hearts Jack      Clubs Six
## 1593    Hearts Jack      Clubs Ten
## 1594    Hearts Jack    Clubs Three
## 1595    Hearts Jack   Diamonds Ace
## 1596    Hearts Jack Diamonds Deuce
## 1597    Hearts Jack Diamonds Eight
## 1598    Hearts Jack  Diamonds Five
## 1599    Hearts Jack  Diamonds Four
## 1600    Hearts Jack  Diamonds Jack
## 1601    Hearts Jack  Diamonds King
## 1602    Hearts Jack  Diamonds Nine
## 1603    Hearts Jack Diamonds Queen
## 1604    Hearts Jack Diamonds Seven
## 1605    Hearts Jack   Diamonds Six
## 1606    Hearts Jack   Diamonds Ten
## 1607    Hearts Jack Diamonds Three
## 1608    Hearts Jack     Hearts Ace
## 1609    Hearts Jack   Hearts Deuce
## 1610    Hearts Jack   Hearts Eight
## 1611    Hearts Jack    Hearts Five
## 1612    Hearts Jack    Hearts Four
## 1613    Hearts Jack    Hearts King
## 1614    Hearts Jack    Hearts Nine
## 1615    Hearts Jack   Hearts Queen
## 1616    Hearts Jack   Hearts Seven
## 1617    Hearts Jack     Hearts Six
## 1618    Hearts Jack     Hearts Ten
## 1619    Hearts Jack   Hearts Three
## 1620    Hearts Jack     Spades Ace
## 1621    Hearts Jack   Spades Deuce
## 1622    Hearts Jack   Spades Eight
## 1623    Hearts Jack    Spades Five
## 1624    Hearts Jack    Spades Four
## 1625    Hearts Jack    Spades Jack
## 1626    Hearts Jack    Spades King
## 1627    Hearts Jack    Spades Nine
## 1628    Hearts Jack   Spades Queen
## 1629    Hearts Jack   Spades Seven
## 1630    Hearts Jack     Spades Six
## 1631    Hearts Jack     Spades Ten
## 1632    Hearts Jack   Spades Three
## 1633    Hearts King      Clubs Ace
## 1634    Hearts King    Clubs Deuce
## 1635    Hearts King    Clubs Eight
## 1636    Hearts King     Clubs Five
## 1637    Hearts King     Clubs Four
## 1638    Hearts King     Clubs Jack
## 1639    Hearts King     Clubs King
## 1640    Hearts King     Clubs Nine
## 1641    Hearts King    Clubs Queen
## 1642    Hearts King    Clubs Seven
## 1643    Hearts King      Clubs Six
## 1644    Hearts King      Clubs Ten
## 1645    Hearts King    Clubs Three
## 1646    Hearts King   Diamonds Ace
## 1647    Hearts King Diamonds Deuce
## 1648    Hearts King Diamonds Eight
## 1649    Hearts King  Diamonds Five
## 1650    Hearts King  Diamonds Four
## 1651    Hearts King  Diamonds Jack
## 1652    Hearts King  Diamonds King
## 1653    Hearts King  Diamonds Nine
## 1654    Hearts King Diamonds Queen
## 1655    Hearts King Diamonds Seven
## 1656    Hearts King   Diamonds Six
## 1657    Hearts King   Diamonds Ten
## 1658    Hearts King Diamonds Three
## 1659    Hearts King     Hearts Ace
## 1660    Hearts King   Hearts Deuce
## 1661    Hearts King   Hearts Eight
## 1662    Hearts King    Hearts Five
## 1663    Hearts King    Hearts Four
## 1664    Hearts King    Hearts Jack
## 1665    Hearts King    Hearts Nine
## 1666    Hearts King   Hearts Queen
## 1667    Hearts King   Hearts Seven
## 1668    Hearts King     Hearts Six
## 1669    Hearts King     Hearts Ten
## 1670    Hearts King   Hearts Three
## 1671    Hearts King     Spades Ace
## 1672    Hearts King   Spades Deuce
## 1673    Hearts King   Spades Eight
## 1674    Hearts King    Spades Five
## 1675    Hearts King    Spades Four
## 1676    Hearts King    Spades Jack
## 1677    Hearts King    Spades King
## 1678    Hearts King    Spades Nine
## 1679    Hearts King   Spades Queen
## 1680    Hearts King   Spades Seven
## 1681    Hearts King     Spades Six
## 1682    Hearts King     Spades Ten
## 1683    Hearts King   Spades Three
## 1684    Hearts Nine      Clubs Ace
## 1685    Hearts Nine    Clubs Deuce
## 1686    Hearts Nine    Clubs Eight
## 1687    Hearts Nine     Clubs Five
## 1688    Hearts Nine     Clubs Four
## 1689    Hearts Nine     Clubs Jack
## 1690    Hearts Nine     Clubs King
## 1691    Hearts Nine     Clubs Nine
## 1692    Hearts Nine    Clubs Queen
## 1693    Hearts Nine    Clubs Seven
## 1694    Hearts Nine      Clubs Six
## 1695    Hearts Nine      Clubs Ten
## 1696    Hearts Nine    Clubs Three
## 1697    Hearts Nine   Diamonds Ace
## 1698    Hearts Nine Diamonds Deuce
## 1699    Hearts Nine Diamonds Eight
## 1700    Hearts Nine  Diamonds Five
## 1701    Hearts Nine  Diamonds Four
## 1702    Hearts Nine  Diamonds Jack
## 1703    Hearts Nine  Diamonds King
## 1704    Hearts Nine  Diamonds Nine
## 1705    Hearts Nine Diamonds Queen
## 1706    Hearts Nine Diamonds Seven
## 1707    Hearts Nine   Diamonds Six
## 1708    Hearts Nine   Diamonds Ten
## 1709    Hearts Nine Diamonds Three
## 1710    Hearts Nine     Hearts Ace
## 1711    Hearts Nine   Hearts Deuce
## 1712    Hearts Nine   Hearts Eight
## 1713    Hearts Nine    Hearts Five
## 1714    Hearts Nine    Hearts Four
## 1715    Hearts Nine    Hearts Jack
## 1716    Hearts Nine    Hearts King
## 1717    Hearts Nine   Hearts Queen
## 1718    Hearts Nine   Hearts Seven
## 1719    Hearts Nine     Hearts Six
## 1720    Hearts Nine     Hearts Ten
## 1721    Hearts Nine   Hearts Three
## 1722    Hearts Nine     Spades Ace
## 1723    Hearts Nine   Spades Deuce
## 1724    Hearts Nine   Spades Eight
## 1725    Hearts Nine    Spades Five
## 1726    Hearts Nine    Spades Four
## 1727    Hearts Nine    Spades Jack
## 1728    Hearts Nine    Spades King
## 1729    Hearts Nine    Spades Nine
## 1730    Hearts Nine   Spades Queen
## 1731    Hearts Nine   Spades Seven
## 1732    Hearts Nine     Spades Six
## 1733    Hearts Nine     Spades Ten
## 1734    Hearts Nine   Spades Three
## 1735   Hearts Queen      Clubs Ace
## 1736   Hearts Queen    Clubs Deuce
## 1737   Hearts Queen    Clubs Eight
## 1738   Hearts Queen     Clubs Five
## 1739   Hearts Queen     Clubs Four
## 1740   Hearts Queen     Clubs Jack
## 1741   Hearts Queen     Clubs King
## 1742   Hearts Queen     Clubs Nine
## 1743   Hearts Queen    Clubs Queen
## 1744   Hearts Queen    Clubs Seven
## 1745   Hearts Queen      Clubs Six
## 1746   Hearts Queen      Clubs Ten
## 1747   Hearts Queen    Clubs Three
## 1748   Hearts Queen   Diamonds Ace
## 1749   Hearts Queen Diamonds Deuce
## 1750   Hearts Queen Diamonds Eight
## 1751   Hearts Queen  Diamonds Five
## 1752   Hearts Queen  Diamonds Four
## 1753   Hearts Queen  Diamonds Jack
## 1754   Hearts Queen  Diamonds King
## 1755   Hearts Queen  Diamonds Nine
## 1756   Hearts Queen Diamonds Queen
## 1757   Hearts Queen Diamonds Seven
## 1758   Hearts Queen   Diamonds Six
## 1759   Hearts Queen   Diamonds Ten
## 1760   Hearts Queen Diamonds Three
## 1761   Hearts Queen     Hearts Ace
## 1762   Hearts Queen   Hearts Deuce
## 1763   Hearts Queen   Hearts Eight
## 1764   Hearts Queen    Hearts Five
## 1765   Hearts Queen    Hearts Four
## 1766   Hearts Queen    Hearts Jack
## 1767   Hearts Queen    Hearts King
## 1768   Hearts Queen    Hearts Nine
## 1769   Hearts Queen   Hearts Seven
## 1770   Hearts Queen     Hearts Six
## 1771   Hearts Queen     Hearts Ten
## 1772   Hearts Queen   Hearts Three
## 1773   Hearts Queen     Spades Ace
## 1774   Hearts Queen   Spades Deuce
## 1775   Hearts Queen   Spades Eight
## 1776   Hearts Queen    Spades Five
## 1777   Hearts Queen    Spades Four
## 1778   Hearts Queen    Spades Jack
## 1779   Hearts Queen    Spades King
## 1780   Hearts Queen    Spades Nine
## 1781   Hearts Queen   Spades Queen
## 1782   Hearts Queen   Spades Seven
## 1783   Hearts Queen     Spades Six
## 1784   Hearts Queen     Spades Ten
## 1785   Hearts Queen   Spades Three
## 1786   Hearts Seven      Clubs Ace
## 1787   Hearts Seven    Clubs Deuce
## 1788   Hearts Seven    Clubs Eight
## 1789   Hearts Seven     Clubs Five
## 1790   Hearts Seven     Clubs Four
## 1791   Hearts Seven     Clubs Jack
## 1792   Hearts Seven     Clubs King
## 1793   Hearts Seven     Clubs Nine
## 1794   Hearts Seven    Clubs Queen
## 1795   Hearts Seven    Clubs Seven
## 1796   Hearts Seven      Clubs Six
## 1797   Hearts Seven      Clubs Ten
## 1798   Hearts Seven    Clubs Three
## 1799   Hearts Seven   Diamonds Ace
## 1800   Hearts Seven Diamonds Deuce
## 1801   Hearts Seven Diamonds Eight
## 1802   Hearts Seven  Diamonds Five
## 1803   Hearts Seven  Diamonds Four
## 1804   Hearts Seven  Diamonds Jack
## 1805   Hearts Seven  Diamonds King
## 1806   Hearts Seven  Diamonds Nine
## 1807   Hearts Seven Diamonds Queen
## 1808   Hearts Seven Diamonds Seven
## 1809   Hearts Seven   Diamonds Six
## 1810   Hearts Seven   Diamonds Ten
## 1811   Hearts Seven Diamonds Three
## 1812   Hearts Seven     Hearts Ace
## 1813   Hearts Seven   Hearts Deuce
## 1814   Hearts Seven   Hearts Eight
## 1815   Hearts Seven    Hearts Five
## 1816   Hearts Seven    Hearts Four
## 1817   Hearts Seven    Hearts Jack
## 1818   Hearts Seven    Hearts King
## 1819   Hearts Seven    Hearts Nine
## 1820   Hearts Seven   Hearts Queen
## 1821   Hearts Seven     Hearts Six
## 1822   Hearts Seven     Hearts Ten
## 1823   Hearts Seven   Hearts Three
## 1824   Hearts Seven     Spades Ace
## 1825   Hearts Seven   Spades Deuce
## 1826   Hearts Seven   Spades Eight
## 1827   Hearts Seven    Spades Five
## 1828   Hearts Seven    Spades Four
## 1829   Hearts Seven    Spades Jack
## 1830   Hearts Seven    Spades King
## 1831   Hearts Seven    Spades Nine
## 1832   Hearts Seven   Spades Queen
## 1833   Hearts Seven   Spades Seven
## 1834   Hearts Seven     Spades Six
## 1835   Hearts Seven     Spades Ten
## 1836   Hearts Seven   Spades Three
## 1837     Hearts Six      Clubs Ace
## 1838     Hearts Six    Clubs Deuce
## 1839     Hearts Six    Clubs Eight
## 1840     Hearts Six     Clubs Five
## 1841     Hearts Six     Clubs Four
## 1842     Hearts Six     Clubs Jack
## 1843     Hearts Six     Clubs King
## 1844     Hearts Six     Clubs Nine
## 1845     Hearts Six    Clubs Queen
## 1846     Hearts Six    Clubs Seven
## 1847     Hearts Six      Clubs Six
## 1848     Hearts Six      Clubs Ten
## 1849     Hearts Six    Clubs Three
## 1850     Hearts Six   Diamonds Ace
## 1851     Hearts Six Diamonds Deuce
## 1852     Hearts Six Diamonds Eight
## 1853     Hearts Six  Diamonds Five
## 1854     Hearts Six  Diamonds Four
## 1855     Hearts Six  Diamonds Jack
## 1856     Hearts Six  Diamonds King
## 1857     Hearts Six  Diamonds Nine
## 1858     Hearts Six Diamonds Queen
## 1859     Hearts Six Diamonds Seven
## 1860     Hearts Six   Diamonds Six
## 1861     Hearts Six   Diamonds Ten
## 1862     Hearts Six Diamonds Three
## 1863     Hearts Six     Hearts Ace
## 1864     Hearts Six   Hearts Deuce
## 1865     Hearts Six   Hearts Eight
## 1866     Hearts Six    Hearts Five
## 1867     Hearts Six    Hearts Four
## 1868     Hearts Six    Hearts Jack
## 1869     Hearts Six    Hearts King
## 1870     Hearts Six    Hearts Nine
## 1871     Hearts Six   Hearts Queen
## 1872     Hearts Six   Hearts Seven
## 1873     Hearts Six     Hearts Ten
## 1874     Hearts Six   Hearts Three
## 1875     Hearts Six     Spades Ace
## 1876     Hearts Six   Spades Deuce
## 1877     Hearts Six   Spades Eight
## 1878     Hearts Six    Spades Five
## 1879     Hearts Six    Spades Four
## 1880     Hearts Six    Spades Jack
## 1881     Hearts Six    Spades King
## 1882     Hearts Six    Spades Nine
## 1883     Hearts Six   Spades Queen
## 1884     Hearts Six   Spades Seven
## 1885     Hearts Six     Spades Six
## 1886     Hearts Six     Spades Ten
## 1887     Hearts Six   Spades Three
## 1888     Hearts Ten      Clubs Ace
## 1889     Hearts Ten    Clubs Deuce
## 1890     Hearts Ten    Clubs Eight
## 1891     Hearts Ten     Clubs Five
## 1892     Hearts Ten     Clubs Four
## 1893     Hearts Ten     Clubs Jack
## 1894     Hearts Ten     Clubs King
## 1895     Hearts Ten     Clubs Nine
## 1896     Hearts Ten    Clubs Queen
## 1897     Hearts Ten    Clubs Seven
## 1898     Hearts Ten      Clubs Six
## 1899     Hearts Ten      Clubs Ten
## 1900     Hearts Ten    Clubs Three
## 1901     Hearts Ten   Diamonds Ace
## 1902     Hearts Ten Diamonds Deuce
## 1903     Hearts Ten Diamonds Eight
## 1904     Hearts Ten  Diamonds Five
## 1905     Hearts Ten  Diamonds Four
## 1906     Hearts Ten  Diamonds Jack
## 1907     Hearts Ten  Diamonds King
## 1908     Hearts Ten  Diamonds Nine
## 1909     Hearts Ten Diamonds Queen
## 1910     Hearts Ten Diamonds Seven
## 1911     Hearts Ten   Diamonds Six
## 1912     Hearts Ten   Diamonds Ten
## 1913     Hearts Ten Diamonds Three
## 1914     Hearts Ten     Hearts Ace
## 1915     Hearts Ten   Hearts Deuce
## 1916     Hearts Ten   Hearts Eight
## 1917     Hearts Ten    Hearts Five
## 1918     Hearts Ten    Hearts Four
## 1919     Hearts Ten    Hearts Jack
## 1920     Hearts Ten    Hearts King
## 1921     Hearts Ten    Hearts Nine
## 1922     Hearts Ten   Hearts Queen
## 1923     Hearts Ten   Hearts Seven
## 1924     Hearts Ten     Hearts Six
## 1925     Hearts Ten   Hearts Three
## 1926     Hearts Ten     Spades Ace
## 1927     Hearts Ten   Spades Deuce
## 1928     Hearts Ten   Spades Eight
## 1929     Hearts Ten    Spades Five
## 1930     Hearts Ten    Spades Four
## 1931     Hearts Ten    Spades Jack
## 1932     Hearts Ten    Spades King
## 1933     Hearts Ten    Spades Nine
## 1934     Hearts Ten   Spades Queen
## 1935     Hearts Ten   Spades Seven
## 1936     Hearts Ten     Spades Six
## 1937     Hearts Ten     Spades Ten
## 1938     Hearts Ten   Spades Three
## 1939   Hearts Three      Clubs Ace
## 1940   Hearts Three    Clubs Deuce
## 1941   Hearts Three    Clubs Eight
## 1942   Hearts Three     Clubs Five
## 1943   Hearts Three     Clubs Four
## 1944   Hearts Three     Clubs Jack
## 1945   Hearts Three     Clubs King
## 1946   Hearts Three     Clubs Nine
## 1947   Hearts Three    Clubs Queen
## 1948   Hearts Three    Clubs Seven
## 1949   Hearts Three      Clubs Six
## 1950   Hearts Three      Clubs Ten
## 1951   Hearts Three    Clubs Three
## 1952   Hearts Three   Diamonds Ace
## 1953   Hearts Three Diamonds Deuce
## 1954   Hearts Three Diamonds Eight
## 1955   Hearts Three  Diamonds Five
## 1956   Hearts Three  Diamonds Four
## 1957   Hearts Three  Diamonds Jack
## 1958   Hearts Three  Diamonds King
## 1959   Hearts Three  Diamonds Nine
## 1960   Hearts Three Diamonds Queen
## 1961   Hearts Three Diamonds Seven
## 1962   Hearts Three   Diamonds Six
## 1963   Hearts Three   Diamonds Ten
## 1964   Hearts Three Diamonds Three
## 1965   Hearts Three     Hearts Ace
## 1966   Hearts Three   Hearts Deuce
## 1967   Hearts Three   Hearts Eight
## 1968   Hearts Three    Hearts Five
## 1969   Hearts Three    Hearts Four
## 1970   Hearts Three    Hearts Jack
## 1971   Hearts Three    Hearts King
## 1972   Hearts Three    Hearts Nine
## 1973   Hearts Three   Hearts Queen
## 1974   Hearts Three   Hearts Seven
## 1975   Hearts Three     Hearts Six
## 1976   Hearts Three     Hearts Ten
## 1977   Hearts Three     Spades Ace
## 1978   Hearts Three   Spades Deuce
## 1979   Hearts Three   Spades Eight
## 1980   Hearts Three    Spades Five
## 1981   Hearts Three    Spades Four
## 1982   Hearts Three    Spades Jack
## 1983   Hearts Three    Spades King
## 1984   Hearts Three    Spades Nine
## 1985   Hearts Three   Spades Queen
## 1986   Hearts Three   Spades Seven
## 1987   Hearts Three     Spades Six
## 1988   Hearts Three     Spades Ten
## 1989   Hearts Three   Spades Three
## 1990     Spades Ace      Clubs Ace
## 1991     Spades Ace    Clubs Deuce
## 1992     Spades Ace    Clubs Eight
## 1993     Spades Ace     Clubs Five
## 1994     Spades Ace     Clubs Four
## 1995     Spades Ace     Clubs Jack
## 1996     Spades Ace     Clubs King
## 1997     Spades Ace     Clubs Nine
## 1998     Spades Ace    Clubs Queen
## 1999     Spades Ace    Clubs Seven
## 2000     Spades Ace      Clubs Six
## 2001     Spades Ace      Clubs Ten
## 2002     Spades Ace    Clubs Three
## 2003     Spades Ace   Diamonds Ace
## 2004     Spades Ace Diamonds Deuce
## 2005     Spades Ace Diamonds Eight
## 2006     Spades Ace  Diamonds Five
## 2007     Spades Ace  Diamonds Four
## 2008     Spades Ace  Diamonds Jack
## 2009     Spades Ace  Diamonds King
## 2010     Spades Ace  Diamonds Nine
## 2011     Spades Ace Diamonds Queen
## 2012     Spades Ace Diamonds Seven
## 2013     Spades Ace   Diamonds Six
## 2014     Spades Ace   Diamonds Ten
## 2015     Spades Ace Diamonds Three
## 2016     Spades Ace     Hearts Ace
## 2017     Spades Ace   Hearts Deuce
## 2018     Spades Ace   Hearts Eight
## 2019     Spades Ace    Hearts Five
## 2020     Spades Ace    Hearts Four
## 2021     Spades Ace    Hearts Jack
## 2022     Spades Ace    Hearts King
## 2023     Spades Ace    Hearts Nine
## 2024     Spades Ace   Hearts Queen
## 2025     Spades Ace   Hearts Seven
## 2026     Spades Ace     Hearts Six
## 2027     Spades Ace     Hearts Ten
## 2028     Spades Ace   Hearts Three
## 2029     Spades Ace   Spades Deuce
## 2030     Spades Ace   Spades Eight
## 2031     Spades Ace    Spades Five
## 2032     Spades Ace    Spades Four
## 2033     Spades Ace    Spades Jack
## 2034     Spades Ace    Spades King
## 2035     Spades Ace    Spades Nine
## 2036     Spades Ace   Spades Queen
## 2037     Spades Ace   Spades Seven
## 2038     Spades Ace     Spades Six
## 2039     Spades Ace     Spades Ten
## 2040     Spades Ace   Spades Three
## 2041   Spades Deuce      Clubs Ace
## 2042   Spades Deuce    Clubs Deuce
## 2043   Spades Deuce    Clubs Eight
## 2044   Spades Deuce     Clubs Five
## 2045   Spades Deuce     Clubs Four
## 2046   Spades Deuce     Clubs Jack
## 2047   Spades Deuce     Clubs King
## 2048   Spades Deuce     Clubs Nine
## 2049   Spades Deuce    Clubs Queen
## 2050   Spades Deuce    Clubs Seven
## 2051   Spades Deuce      Clubs Six
## 2052   Spades Deuce      Clubs Ten
## 2053   Spades Deuce    Clubs Three
## 2054   Spades Deuce   Diamonds Ace
## 2055   Spades Deuce Diamonds Deuce
## 2056   Spades Deuce Diamonds Eight
## 2057   Spades Deuce  Diamonds Five
## 2058   Spades Deuce  Diamonds Four
## 2059   Spades Deuce  Diamonds Jack
## 2060   Spades Deuce  Diamonds King
## 2061   Spades Deuce  Diamonds Nine
## 2062   Spades Deuce Diamonds Queen
## 2063   Spades Deuce Diamonds Seven
## 2064   Spades Deuce   Diamonds Six
## 2065   Spades Deuce   Diamonds Ten
## 2066   Spades Deuce Diamonds Three
## 2067   Spades Deuce     Hearts Ace
## 2068   Spades Deuce   Hearts Deuce
## 2069   Spades Deuce   Hearts Eight
## 2070   Spades Deuce    Hearts Five
## 2071   Spades Deuce    Hearts Four
## 2072   Spades Deuce    Hearts Jack
## 2073   Spades Deuce    Hearts King
## 2074   Spades Deuce    Hearts Nine
## 2075   Spades Deuce   Hearts Queen
## 2076   Spades Deuce   Hearts Seven
## 2077   Spades Deuce     Hearts Six
## 2078   Spades Deuce     Hearts Ten
## 2079   Spades Deuce   Hearts Three
## 2080   Spades Deuce     Spades Ace
## 2081   Spades Deuce   Spades Eight
## 2082   Spades Deuce    Spades Five
## 2083   Spades Deuce    Spades Four
## 2084   Spades Deuce    Spades Jack
## 2085   Spades Deuce    Spades King
## 2086   Spades Deuce    Spades Nine
## 2087   Spades Deuce   Spades Queen
## 2088   Spades Deuce   Spades Seven
## 2089   Spades Deuce     Spades Six
## 2090   Spades Deuce     Spades Ten
## 2091   Spades Deuce   Spades Three
## 2092   Spades Eight      Clubs Ace
## 2093   Spades Eight    Clubs Deuce
## 2094   Spades Eight    Clubs Eight
## 2095   Spades Eight     Clubs Five
## 2096   Spades Eight     Clubs Four
## 2097   Spades Eight     Clubs Jack
## 2098   Spades Eight     Clubs King
## 2099   Spades Eight     Clubs Nine
## 2100   Spades Eight    Clubs Queen
## 2101   Spades Eight    Clubs Seven
## 2102   Spades Eight      Clubs Six
## 2103   Spades Eight      Clubs Ten
## 2104   Spades Eight    Clubs Three
## 2105   Spades Eight   Diamonds Ace
## 2106   Spades Eight Diamonds Deuce
## 2107   Spades Eight Diamonds Eight
## 2108   Spades Eight  Diamonds Five
## 2109   Spades Eight  Diamonds Four
## 2110   Spades Eight  Diamonds Jack
## 2111   Spades Eight  Diamonds King
## 2112   Spades Eight  Diamonds Nine
## 2113   Spades Eight Diamonds Queen
## 2114   Spades Eight Diamonds Seven
## 2115   Spades Eight   Diamonds Six
## 2116   Spades Eight   Diamonds Ten
## 2117   Spades Eight Diamonds Three
## 2118   Spades Eight     Hearts Ace
## 2119   Spades Eight   Hearts Deuce
## 2120   Spades Eight   Hearts Eight
## 2121   Spades Eight    Hearts Five
## 2122   Spades Eight    Hearts Four
## 2123   Spades Eight    Hearts Jack
## 2124   Spades Eight    Hearts King
## 2125   Spades Eight    Hearts Nine
## 2126   Spades Eight   Hearts Queen
## 2127   Spades Eight   Hearts Seven
## 2128   Spades Eight     Hearts Six
## 2129   Spades Eight     Hearts Ten
## 2130   Spades Eight   Hearts Three
## 2131   Spades Eight     Spades Ace
## 2132   Spades Eight   Spades Deuce
## 2133   Spades Eight    Spades Five
## 2134   Spades Eight    Spades Four
## 2135   Spades Eight    Spades Jack
## 2136   Spades Eight    Spades King
## 2137   Spades Eight    Spades Nine
## 2138   Spades Eight   Spades Queen
## 2139   Spades Eight   Spades Seven
## 2140   Spades Eight     Spades Six
## 2141   Spades Eight     Spades Ten
## 2142   Spades Eight   Spades Three
## 2143    Spades Five      Clubs Ace
## 2144    Spades Five    Clubs Deuce
## 2145    Spades Five    Clubs Eight
## 2146    Spades Five     Clubs Five
## 2147    Spades Five     Clubs Four
## 2148    Spades Five     Clubs Jack
## 2149    Spades Five     Clubs King
## 2150    Spades Five     Clubs Nine
## 2151    Spades Five    Clubs Queen
## 2152    Spades Five    Clubs Seven
## 2153    Spades Five      Clubs Six
## 2154    Spades Five      Clubs Ten
## 2155    Spades Five    Clubs Three
## 2156    Spades Five   Diamonds Ace
## 2157    Spades Five Diamonds Deuce
## 2158    Spades Five Diamonds Eight
## 2159    Spades Five  Diamonds Five
## 2160    Spades Five  Diamonds Four
## 2161    Spades Five  Diamonds Jack
## 2162    Spades Five  Diamonds King
## 2163    Spades Five  Diamonds Nine
## 2164    Spades Five Diamonds Queen
## 2165    Spades Five Diamonds Seven
## 2166    Spades Five   Diamonds Six
## 2167    Spades Five   Diamonds Ten
## 2168    Spades Five Diamonds Three
## 2169    Spades Five     Hearts Ace
## 2170    Spades Five   Hearts Deuce
## 2171    Spades Five   Hearts Eight
## 2172    Spades Five    Hearts Five
## 2173    Spades Five    Hearts Four
## 2174    Spades Five    Hearts Jack
## 2175    Spades Five    Hearts King
## 2176    Spades Five    Hearts Nine
## 2177    Spades Five   Hearts Queen
## 2178    Spades Five   Hearts Seven
## 2179    Spades Five     Hearts Six
## 2180    Spades Five     Hearts Ten
## 2181    Spades Five   Hearts Three
## 2182    Spades Five     Spades Ace
## 2183    Spades Five   Spades Deuce
## 2184    Spades Five   Spades Eight
## 2185    Spades Five    Spades Four
## 2186    Spades Five    Spades Jack
## 2187    Spades Five    Spades King
## 2188    Spades Five    Spades Nine
## 2189    Spades Five   Spades Queen
## 2190    Spades Five   Spades Seven
## 2191    Spades Five     Spades Six
## 2192    Spades Five     Spades Ten
## 2193    Spades Five   Spades Three
## 2194    Spades Four      Clubs Ace
## 2195    Spades Four    Clubs Deuce
## 2196    Spades Four    Clubs Eight
## 2197    Spades Four     Clubs Five
## 2198    Spades Four     Clubs Four
## 2199    Spades Four     Clubs Jack
## 2200    Spades Four     Clubs King
## 2201    Spades Four     Clubs Nine
## 2202    Spades Four    Clubs Queen
## 2203    Spades Four    Clubs Seven
## 2204    Spades Four      Clubs Six
## 2205    Spades Four      Clubs Ten
## 2206    Spades Four    Clubs Three
## 2207    Spades Four   Diamonds Ace
## 2208    Spades Four Diamonds Deuce
## 2209    Spades Four Diamonds Eight
## 2210    Spades Four  Diamonds Five
## 2211    Spades Four  Diamonds Four
## 2212    Spades Four  Diamonds Jack
## 2213    Spades Four  Diamonds King
## 2214    Spades Four  Diamonds Nine
## 2215    Spades Four Diamonds Queen
## 2216    Spades Four Diamonds Seven
## 2217    Spades Four   Diamonds Six
## 2218    Spades Four   Diamonds Ten
## 2219    Spades Four Diamonds Three
## 2220    Spades Four     Hearts Ace
## 2221    Spades Four   Hearts Deuce
## 2222    Spades Four   Hearts Eight
## 2223    Spades Four    Hearts Five
## 2224    Spades Four    Hearts Four
## 2225    Spades Four    Hearts Jack
## 2226    Spades Four    Hearts King
## 2227    Spades Four    Hearts Nine
## 2228    Spades Four   Hearts Queen
## 2229    Spades Four   Hearts Seven
## 2230    Spades Four     Hearts Six
## 2231    Spades Four     Hearts Ten
## 2232    Spades Four   Hearts Three
## 2233    Spades Four     Spades Ace
## 2234    Spades Four   Spades Deuce
## 2235    Spades Four   Spades Eight
## 2236    Spades Four    Spades Five
## 2237    Spades Four    Spades Jack
## 2238    Spades Four    Spades King
## 2239    Spades Four    Spades Nine
## 2240    Spades Four   Spades Queen
## 2241    Spades Four   Spades Seven
## 2242    Spades Four     Spades Six
## 2243    Spades Four     Spades Ten
## 2244    Spades Four   Spades Three
## 2245    Spades Jack      Clubs Ace
## 2246    Spades Jack    Clubs Deuce
## 2247    Spades Jack    Clubs Eight
## 2248    Spades Jack     Clubs Five
## 2249    Spades Jack     Clubs Four
## 2250    Spades Jack     Clubs Jack
## 2251    Spades Jack     Clubs King
## 2252    Spades Jack     Clubs Nine
## 2253    Spades Jack    Clubs Queen
## 2254    Spades Jack    Clubs Seven
## 2255    Spades Jack      Clubs Six
## 2256    Spades Jack      Clubs Ten
## 2257    Spades Jack    Clubs Three
## 2258    Spades Jack   Diamonds Ace
## 2259    Spades Jack Diamonds Deuce
## 2260    Spades Jack Diamonds Eight
## 2261    Spades Jack  Diamonds Five
## 2262    Spades Jack  Diamonds Four
## 2263    Spades Jack  Diamonds Jack
## 2264    Spades Jack  Diamonds King
## 2265    Spades Jack  Diamonds Nine
## 2266    Spades Jack Diamonds Queen
## 2267    Spades Jack Diamonds Seven
## 2268    Spades Jack   Diamonds Six
## 2269    Spades Jack   Diamonds Ten
## 2270    Spades Jack Diamonds Three
## 2271    Spades Jack     Hearts Ace
## 2272    Spades Jack   Hearts Deuce
## 2273    Spades Jack   Hearts Eight
## 2274    Spades Jack    Hearts Five
## 2275    Spades Jack    Hearts Four
## 2276    Spades Jack    Hearts Jack
## 2277    Spades Jack    Hearts King
## 2278    Spades Jack    Hearts Nine
## 2279    Spades Jack   Hearts Queen
## 2280    Spades Jack   Hearts Seven
## 2281    Spades Jack     Hearts Six
## 2282    Spades Jack     Hearts Ten
## 2283    Spades Jack   Hearts Three
## 2284    Spades Jack     Spades Ace
## 2285    Spades Jack   Spades Deuce
## 2286    Spades Jack   Spades Eight
## 2287    Spades Jack    Spades Five
## 2288    Spades Jack    Spades Four
## 2289    Spades Jack    Spades King
## 2290    Spades Jack    Spades Nine
## 2291    Spades Jack   Spades Queen
## 2292    Spades Jack   Spades Seven
## 2293    Spades Jack     Spades Six
## 2294    Spades Jack     Spades Ten
## 2295    Spades Jack   Spades Three
## 2296    Spades King      Clubs Ace
## 2297    Spades King    Clubs Deuce
## 2298    Spades King    Clubs Eight
## 2299    Spades King     Clubs Five
## 2300    Spades King     Clubs Four
## 2301    Spades King     Clubs Jack
## 2302    Spades King     Clubs King
## 2303    Spades King     Clubs Nine
## 2304    Spades King    Clubs Queen
## 2305    Spades King    Clubs Seven
## 2306    Spades King      Clubs Six
## 2307    Spades King      Clubs Ten
## 2308    Spades King    Clubs Three
## 2309    Spades King   Diamonds Ace
## 2310    Spades King Diamonds Deuce
## 2311    Spades King Diamonds Eight
## 2312    Spades King  Diamonds Five
## 2313    Spades King  Diamonds Four
## 2314    Spades King  Diamonds Jack
## 2315    Spades King  Diamonds King
## 2316    Spades King  Diamonds Nine
## 2317    Spades King Diamonds Queen
## 2318    Spades King Diamonds Seven
## 2319    Spades King   Diamonds Six
## 2320    Spades King   Diamonds Ten
## 2321    Spades King Diamonds Three
## 2322    Spades King     Hearts Ace
## 2323    Spades King   Hearts Deuce
## 2324    Spades King   Hearts Eight
## 2325    Spades King    Hearts Five
## 2326    Spades King    Hearts Four
## 2327    Spades King    Hearts Jack
## 2328    Spades King    Hearts King
## 2329    Spades King    Hearts Nine
## 2330    Spades King   Hearts Queen
## 2331    Spades King   Hearts Seven
## 2332    Spades King     Hearts Six
## 2333    Spades King     Hearts Ten
## 2334    Spades King   Hearts Three
## 2335    Spades King     Spades Ace
## 2336    Spades King   Spades Deuce
## 2337    Spades King   Spades Eight
## 2338    Spades King    Spades Five
## 2339    Spades King    Spades Four
## 2340    Spades King    Spades Jack
## 2341    Spades King    Spades Nine
## 2342    Spades King   Spades Queen
## 2343    Spades King   Spades Seven
## 2344    Spades King     Spades Six
## 2345    Spades King     Spades Ten
## 2346    Spades King   Spades Three
## 2347    Spades Nine      Clubs Ace
## 2348    Spades Nine    Clubs Deuce
## 2349    Spades Nine    Clubs Eight
## 2350    Spades Nine     Clubs Five
## 2351    Spades Nine     Clubs Four
## 2352    Spades Nine     Clubs Jack
## 2353    Spades Nine     Clubs King
## 2354    Spades Nine     Clubs Nine
## 2355    Spades Nine    Clubs Queen
## 2356    Spades Nine    Clubs Seven
## 2357    Spades Nine      Clubs Six
## 2358    Spades Nine      Clubs Ten
## 2359    Spades Nine    Clubs Three
## 2360    Spades Nine   Diamonds Ace
## 2361    Spades Nine Diamonds Deuce
## 2362    Spades Nine Diamonds Eight
## 2363    Spades Nine  Diamonds Five
## 2364    Spades Nine  Diamonds Four
## 2365    Spades Nine  Diamonds Jack
## 2366    Spades Nine  Diamonds King
## 2367    Spades Nine  Diamonds Nine
## 2368    Spades Nine Diamonds Queen
## 2369    Spades Nine Diamonds Seven
## 2370    Spades Nine   Diamonds Six
## 2371    Spades Nine   Diamonds Ten
## 2372    Spades Nine Diamonds Three
## 2373    Spades Nine     Hearts Ace
## 2374    Spades Nine   Hearts Deuce
## 2375    Spades Nine   Hearts Eight
## 2376    Spades Nine    Hearts Five
## 2377    Spades Nine    Hearts Four
## 2378    Spades Nine    Hearts Jack
## 2379    Spades Nine    Hearts King
## 2380    Spades Nine    Hearts Nine
## 2381    Spades Nine   Hearts Queen
## 2382    Spades Nine   Hearts Seven
## 2383    Spades Nine     Hearts Six
## 2384    Spades Nine     Hearts Ten
## 2385    Spades Nine   Hearts Three
## 2386    Spades Nine     Spades Ace
## 2387    Spades Nine   Spades Deuce
## 2388    Spades Nine   Spades Eight
## 2389    Spades Nine    Spades Five
## 2390    Spades Nine    Spades Four
## 2391    Spades Nine    Spades Jack
## 2392    Spades Nine    Spades King
## 2393    Spades Nine   Spades Queen
## 2394    Spades Nine   Spades Seven
## 2395    Spades Nine     Spades Six
## 2396    Spades Nine     Spades Ten
## 2397    Spades Nine   Spades Three
## 2398   Spades Queen      Clubs Ace
## 2399   Spades Queen    Clubs Deuce
## 2400   Spades Queen    Clubs Eight
## 2401   Spades Queen     Clubs Five
## 2402   Spades Queen     Clubs Four
## 2403   Spades Queen     Clubs Jack
## 2404   Spades Queen     Clubs King
## 2405   Spades Queen     Clubs Nine
## 2406   Spades Queen    Clubs Queen
## 2407   Spades Queen    Clubs Seven
## 2408   Spades Queen      Clubs Six
## 2409   Spades Queen      Clubs Ten
## 2410   Spades Queen    Clubs Three
## 2411   Spades Queen   Diamonds Ace
## 2412   Spades Queen Diamonds Deuce
## 2413   Spades Queen Diamonds Eight
## 2414   Spades Queen  Diamonds Five
## 2415   Spades Queen  Diamonds Four
## 2416   Spades Queen  Diamonds Jack
## 2417   Spades Queen  Diamonds King
## 2418   Spades Queen  Diamonds Nine
## 2419   Spades Queen Diamonds Queen
## 2420   Spades Queen Diamonds Seven
## 2421   Spades Queen   Diamonds Six
## 2422   Spades Queen   Diamonds Ten
## 2423   Spades Queen Diamonds Three
## 2424   Spades Queen     Hearts Ace
## 2425   Spades Queen   Hearts Deuce
## 2426   Spades Queen   Hearts Eight
## 2427   Spades Queen    Hearts Five
## 2428   Spades Queen    Hearts Four
## 2429   Spades Queen    Hearts Jack
## 2430   Spades Queen    Hearts King
## 2431   Spades Queen    Hearts Nine
## 2432   Spades Queen   Hearts Queen
## 2433   Spades Queen   Hearts Seven
## 2434   Spades Queen     Hearts Six
## 2435   Spades Queen     Hearts Ten
## 2436   Spades Queen   Hearts Three
## 2437   Spades Queen     Spades Ace
## 2438   Spades Queen   Spades Deuce
## 2439   Spades Queen   Spades Eight
## 2440   Spades Queen    Spades Five
## 2441   Spades Queen    Spades Four
## 2442   Spades Queen    Spades Jack
## 2443   Spades Queen    Spades King
## 2444   Spades Queen    Spades Nine
## 2445   Spades Queen   Spades Seven
## 2446   Spades Queen     Spades Six
## 2447   Spades Queen     Spades Ten
## 2448   Spades Queen   Spades Three
## 2449   Spades Seven      Clubs Ace
## 2450   Spades Seven    Clubs Deuce
## 2451   Spades Seven    Clubs Eight
## 2452   Spades Seven     Clubs Five
## 2453   Spades Seven     Clubs Four
## 2454   Spades Seven     Clubs Jack
## 2455   Spades Seven     Clubs King
## 2456   Spades Seven     Clubs Nine
## 2457   Spades Seven    Clubs Queen
## 2458   Spades Seven    Clubs Seven
## 2459   Spades Seven      Clubs Six
## 2460   Spades Seven      Clubs Ten
## 2461   Spades Seven    Clubs Three
## 2462   Spades Seven   Diamonds Ace
## 2463   Spades Seven Diamonds Deuce
## 2464   Spades Seven Diamonds Eight
## 2465   Spades Seven  Diamonds Five
## 2466   Spades Seven  Diamonds Four
## 2467   Spades Seven  Diamonds Jack
## 2468   Spades Seven  Diamonds King
## 2469   Spades Seven  Diamonds Nine
## 2470   Spades Seven Diamonds Queen
## 2471   Spades Seven Diamonds Seven
## 2472   Spades Seven   Diamonds Six
## 2473   Spades Seven   Diamonds Ten
## 2474   Spades Seven Diamonds Three
## 2475   Spades Seven     Hearts Ace
## 2476   Spades Seven   Hearts Deuce
## 2477   Spades Seven   Hearts Eight
## 2478   Spades Seven    Hearts Five
## 2479   Spades Seven    Hearts Four
## 2480   Spades Seven    Hearts Jack
## 2481   Spades Seven    Hearts King
## 2482   Spades Seven    Hearts Nine
## 2483   Spades Seven   Hearts Queen
## 2484   Spades Seven   Hearts Seven
## 2485   Spades Seven     Hearts Six
## 2486   Spades Seven     Hearts Ten
## 2487   Spades Seven   Hearts Three
## 2488   Spades Seven     Spades Ace
## 2489   Spades Seven   Spades Deuce
## 2490   Spades Seven   Spades Eight
## 2491   Spades Seven    Spades Five
## 2492   Spades Seven    Spades Four
## 2493   Spades Seven    Spades Jack
## 2494   Spades Seven    Spades King
## 2495   Spades Seven    Spades Nine
## 2496   Spades Seven   Spades Queen
## 2497   Spades Seven     Spades Six
## 2498   Spades Seven     Spades Ten
## 2499   Spades Seven   Spades Three
## 2500     Spades Six      Clubs Ace
## 2501     Spades Six    Clubs Deuce
## 2502     Spades Six    Clubs Eight
## 2503     Spades Six     Clubs Five
## 2504     Spades Six     Clubs Four
## 2505     Spades Six     Clubs Jack
## 2506     Spades Six     Clubs King
## 2507     Spades Six     Clubs Nine
## 2508     Spades Six    Clubs Queen
## 2509     Spades Six    Clubs Seven
## 2510     Spades Six      Clubs Six
## 2511     Spades Six      Clubs Ten
## 2512     Spades Six    Clubs Three
## 2513     Spades Six   Diamonds Ace
## 2514     Spades Six Diamonds Deuce
## 2515     Spades Six Diamonds Eight
## 2516     Spades Six  Diamonds Five
## 2517     Spades Six  Diamonds Four
## 2518     Spades Six  Diamonds Jack
## 2519     Spades Six  Diamonds King
## 2520     Spades Six  Diamonds Nine
## 2521     Spades Six Diamonds Queen
## 2522     Spades Six Diamonds Seven
## 2523     Spades Six   Diamonds Six
## 2524     Spades Six   Diamonds Ten
## 2525     Spades Six Diamonds Three
## 2526     Spades Six     Hearts Ace
## 2527     Spades Six   Hearts Deuce
## 2528     Spades Six   Hearts Eight
## 2529     Spades Six    Hearts Five
## 2530     Spades Six    Hearts Four
## 2531     Spades Six    Hearts Jack
## 2532     Spades Six    Hearts King
## 2533     Spades Six    Hearts Nine
## 2534     Spades Six   Hearts Queen
## 2535     Spades Six   Hearts Seven
## 2536     Spades Six     Hearts Six
## 2537     Spades Six     Hearts Ten
## 2538     Spades Six   Hearts Three
## 2539     Spades Six     Spades Ace
## 2540     Spades Six   Spades Deuce
## 2541     Spades Six   Spades Eight
## 2542     Spades Six    Spades Five
## 2543     Spades Six    Spades Four
## 2544     Spades Six    Spades Jack
## 2545     Spades Six    Spades King
## 2546     Spades Six    Spades Nine
## 2547     Spades Six   Spades Queen
## 2548     Spades Six   Spades Seven
## 2549     Spades Six     Spades Ten
## 2550     Spades Six   Spades Three
## 2551     Spades Ten      Clubs Ace
## 2552     Spades Ten    Clubs Deuce
## 2553     Spades Ten    Clubs Eight
## 2554     Spades Ten     Clubs Five
## 2555     Spades Ten     Clubs Four
## 2556     Spades Ten     Clubs Jack
## 2557     Spades Ten     Clubs King
## 2558     Spades Ten     Clubs Nine
## 2559     Spades Ten    Clubs Queen
## 2560     Spades Ten    Clubs Seven
## 2561     Spades Ten      Clubs Six
## 2562     Spades Ten      Clubs Ten
## 2563     Spades Ten    Clubs Three
## 2564     Spades Ten   Diamonds Ace
## 2565     Spades Ten Diamonds Deuce
## 2566     Spades Ten Diamonds Eight
## 2567     Spades Ten  Diamonds Five
## 2568     Spades Ten  Diamonds Four
## 2569     Spades Ten  Diamonds Jack
## 2570     Spades Ten  Diamonds King
## 2571     Spades Ten  Diamonds Nine
## 2572     Spades Ten Diamonds Queen
## 2573     Spades Ten Diamonds Seven
## 2574     Spades Ten   Diamonds Six
## 2575     Spades Ten   Diamonds Ten
## 2576     Spades Ten Diamonds Three
## 2577     Spades Ten     Hearts Ace
## 2578     Spades Ten   Hearts Deuce
## 2579     Spades Ten   Hearts Eight
## 2580     Spades Ten    Hearts Five
## 2581     Spades Ten    Hearts Four
## 2582     Spades Ten    Hearts Jack
## 2583     Spades Ten    Hearts King
## 2584     Spades Ten    Hearts Nine
## 2585     Spades Ten   Hearts Queen
## 2586     Spades Ten   Hearts Seven
## 2587     Spades Ten     Hearts Six
## 2588     Spades Ten     Hearts Ten
## 2589     Spades Ten   Hearts Three
## 2590     Spades Ten     Spades Ace
## 2591     Spades Ten   Spades Deuce
## 2592     Spades Ten   Spades Eight
## 2593     Spades Ten    Spades Five
## 2594     Spades Ten    Spades Four
## 2595     Spades Ten    Spades Jack
## 2596     Spades Ten    Spades King
## 2597     Spades Ten    Spades Nine
## 2598     Spades Ten   Spades Queen
## 2599     Spades Ten   Spades Seven
## 2600     Spades Ten     Spades Six
## 2601     Spades Ten   Spades Three
## 2602   Spades Three      Clubs Ace
## 2603   Spades Three    Clubs Deuce
## 2604   Spades Three    Clubs Eight
## 2605   Spades Three     Clubs Five
## 2606   Spades Three     Clubs Four
## 2607   Spades Three     Clubs Jack
## 2608   Spades Three     Clubs King
## 2609   Spades Three     Clubs Nine
## 2610   Spades Three    Clubs Queen
## 2611   Spades Three    Clubs Seven
## 2612   Spades Three      Clubs Six
## 2613   Spades Three      Clubs Ten
## 2614   Spades Three    Clubs Three
## 2615   Spades Three   Diamonds Ace
## 2616   Spades Three Diamonds Deuce
## 2617   Spades Three Diamonds Eight
## 2618   Spades Three  Diamonds Five
## 2619   Spades Three  Diamonds Four
## 2620   Spades Three  Diamonds Jack
## 2621   Spades Three  Diamonds King
## 2622   Spades Three  Diamonds Nine
## 2623   Spades Three Diamonds Queen
## 2624   Spades Three Diamonds Seven
## 2625   Spades Three   Diamonds Six
## 2626   Spades Three   Diamonds Ten
## 2627   Spades Three Diamonds Three
## 2628   Spades Three     Hearts Ace
## 2629   Spades Three   Hearts Deuce
## 2630   Spades Three   Hearts Eight
## 2631   Spades Three    Hearts Five
## 2632   Spades Three    Hearts Four
## 2633   Spades Three    Hearts Jack
## 2634   Spades Three    Hearts King
## 2635   Spades Three    Hearts Nine
## 2636   Spades Three   Hearts Queen
## 2637   Spades Three   Hearts Seven
## 2638   Spades Three     Hearts Six
## 2639   Spades Three     Hearts Ten
## 2640   Spades Three   Hearts Three
## 2641   Spades Three     Spades Ace
## 2642   Spades Three   Spades Deuce
## 2643   Spades Three   Spades Eight
## 2644   Spades Three    Spades Five
## 2645   Spades Three    Spades Four
## 2646   Spades Three    Spades Jack
## 2647   Spades Three    Spades King
## 2648   Spades Three    Spades Nine
## 2649   Spades Three   Spades Queen
## 2650   Spades Three   Spades Seven
## 2651   Spades Three     Spades Six
## 2652   Spades Three     Spades Ten
all_phone_numbers <- permutations(10, 7, v=0:9)
n <- nrow(all_phone_numbers)

index <- sample(n, 5)

all_phone_numbers[index,]
##      [,1] [,2] [,3] [,4] [,5] [,6] [,7]
## [1,]    4    8    2    7    0    3    1
## [2,]    2    0    8    7    3    4    6
## [3,]    6    0    9    3    7    2    1
## [4,]    3    2    8    4    7    1    6
## [5,]    5    9    8    7    3    6    0
library(gtools)

suits <- c("Diamonds", "Clubs", "Hearts", "Spades")
numbers <- c("Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")


deck <- expand.grid(suit = suits, number = numbers)
deck <- paste(deck$suit, deck$number)
deck
##  [1] "Diamonds Ace"   "Clubs Ace"      "Hearts Ace"     "Spades Ace"    
##  [5] "Diamonds Deuce" "Clubs Deuce"    "Hearts Deuce"   "Spades Deuce"  
##  [9] "Diamonds Three" "Clubs Three"    "Hearts Three"   "Spades Three"  
## [13] "Diamonds Four"  "Clubs Four"     "Hearts Four"    "Spades Four"   
## [17] "Diamonds Five"  "Clubs Five"     "Hearts Five"    "Spades Five"   
## [21] "Diamonds Six"   "Clubs Six"      "Hearts Six"     "Spades Six"    
## [25] "Diamonds Seven" "Clubs Seven"    "Hearts Seven"   "Spades Seven"  
## [29] "Diamonds Eight" "Clubs Eight"    "Hearts Eight"   "Spades Eight"  
## [33] "Diamonds Nine"  "Clubs Nine"     "Hearts Nine"    "Spades Nine"   
## [37] "Diamonds Ten"   "Clubs Ten"      "Hearts Ten"     "Spades Ten"    
## [41] "Diamonds Jack"  "Clubs Jack"     "Hearts Jack"    "Spades Jack"   
## [45] "Diamonds Queen" "Clubs Queen"    "Hearts Queen"   "Spades Queen"  
## [49] "Diamonds King"  "Clubs King"     "Hearts King"    "Spades King"
hands <- permutations(52, 2, v = deck)     # ===========================================================================

length(hands[, 1])
## [1] 2652
n = nrow(hands)

index <- sample(n, 6)      # ===========================================================================================

hands[index, ]
##      [,1]           [,2]           
## [1,] "Hearts Queen" "Clubs Three"  
## [2,] "Clubs Queen"  "Hearts Ten"   
## [3,] "Hearts Three" "Diamonds Nine"
## [4,] "Hearts Seven" "Spades Deuce" 
## [5,] "Spades Nine"  "Spades Four"  
## [6,] "Clubs Three"  "Hearts Four"
first_card <- hands[, 1]
second_card <- hands[, 2]

head(second_card)
## [1] "Clubs Deuce" "Clubs Eight" "Clubs Five"  "Clubs Four"  "Clubs Jack" 
## [6] "Clubs King"
length(unique(first_card))
## [1] 52
# first_card %in% kings      # Thank God I tried this code, and find the causation of wrong code
sum(first_card %in% kings)
## [1] 204
sum(first_card %in% kings & second_card %in% kings)/sum(first_card %in% kings)
## [1] 0.05882353

=============================================================================================================================================

how to think this equation in the right way

Yes, this image has to be here

combinations(3, 2)
##      [,1] [,2]
## [1,]    1    2
## [2,]    1    3
## [3,]    2    3
permutations(3, 2)
##      [,1] [,2]
## [1,]    1    2
## [2,]    1    3
## [3,]    2    1
## [4,]    2    3
## [5,]    3    1
## [6,]    3    2
suits
## [1] "Diamonds" "Clubs"    "Hearts"   "Spades"
aces <- paste("Ace", suits)
aces
## [1] "Ace Diamonds" "Ace Clubs"    "Ace Hearts"   "Ace Spades"
facedcard <- c("Ten", "Jack", "Queen", "King")
facedcard_combine <- expand.grid(faces = facedcard, suit = suits)

facedcard_combine <- paste(facedcard_combine$faces, facedcard_combine$suit)


facedcard_combine
##  [1] "Ten Diamonds"   "Jack Diamonds"  "Queen Diamonds" "King Diamonds" 
##  [5] "Ten Clubs"      "Jack Clubs"     "Queen Clubs"    "King Clubs"    
##  [9] "Ten Hearts"     "Jack Hearts"    "Queen Hearts"   "King Hearts"   
## [13] "Ten Spades"     "Jack Spades"    "Queen Spades"   "King Spades"
suits <- c("Diamonds", "Clubs", "Hearts", "Spades")
numbers <- c("Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")


deck <- expand.grid(suit = suits, number = numbers)
deck <- paste(deck$number, deck$suit)


all_hands <- permutations(52, 2, v = deck)      # =========================================================================================
head(all_hands)                                 # First finish this approach, and Notice in Blackjack the natural 21 means cards, not order
##      [,1]        [,2]            
## [1,] "Ace Clubs" "Ace Diamonds"  
## [2,] "Ace Clubs" "Ace Hearts"    
## [3,] "Ace Clubs" "Ace Spades"    
## [4,] "Ace Clubs" "Deuce Clubs"   
## [5,] "Ace Clubs" "Deuce Diamonds"
## [6,] "Ace Clubs" "Deuce Hearts"
# I'll apply the conditional probability equations here: Pr(A and B) = Pr(A) * Pr(B|A)
natural21 <- mean(all_hands[, 1] %in% aces) * sum(all_hands[, 1] %in% aces & all_hands[, 2] %in% facedcard_combine)/sum(all_hands[, 1] %in% aces)
natural21
## [1] 0.02413273
library(gtools)


suits <- c("Clubs", "Diamonds", "Hearts", "Spades")

aces <- paste("Ace", suits)
aces
## [1] "Ace Clubs"    "Ace Diamonds" "Ace Hearts"   "Ace Spades"
facedcard <- c("Ten", "Jack", "Queen", "King")

facedcard_combine <- expand.grid(faces = facedcard, suit = suits)

facedcard_combine <- paste(facedcard_combine$faces, facedcard_combine$suit)
facedcard_combine
##  [1] "Ten Clubs"      "Jack Clubs"     "Queen Clubs"    "King Clubs"    
##  [5] "Ten Diamonds"   "Jack Diamonds"  "Queen Diamonds" "King Diamonds" 
##  [9] "Ten Hearts"     "Jack Hearts"    "Queen Hearts"   "King Hearts"   
## [13] "Ten Spades"     "Jack Spades"    "Queen Spades"   "King Spades"
suits <- c("Diamonds", "Clubs", "Hearts", "Spades")
numbers <- c("Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")


deck <- expand.grid(suit = suits, number = numbers)
deck <- paste(deck$number, deck$suit)




hands <- combinations(52, 2, v = deck)
length(hands[, 2])
## [1] 1326
mean(hands[, 1] %in% aces & hands[, 2] %in% facedcard_combine)
## [1] 0.04826546
mean(hands[, 1] %in% aces & hands[, 2] %in% facedcard_combine) + mean(hands[, 1] %in% facedcard_combine & hands[, 2] %in% aces)
## [1] 0.04826546
# ===============================================================================================================================
# Here we should notice how the combination function works

mean((hands[, 1] %in% aces & hands[, 2] %in% facedcard_combine) | (hands[, 1] %in% facedcard_combine & hands[, 2] %in% aces))
## [1] 0.04826546
hands <- sample(deck, 2)

hands
## [1] "Four Clubs"    "Jack Diamonds"
B <- 100000
result <- replicate(B, {
  hand <- sample(deck, 2)
  (hand[1] %in% aces & hand[2] %in% facedcard_combine) | 
    hand[2] %in% aces & hand[1] %in% facedcard_combine})

mean(result)
## [1] 0.04825

now, how about the second card being a king, given that the first card is king ??? Think about it

Note: these functions are available in gtools package

Notice: here the order maters, and once we pick a number, it cant appear again

But be careful how combination function wroks, as this code seems counterintuitive

The Birthday Problem

Suppose you’re in a classroom with 50 people. If we assume this is a randomly selected group, what is the chance that at least two people have the same birthday? Although it is somewhat advanced, we can actually deduce this mathematically, and we do this later, but now, we’re going to use Monte Carlo simulations. For simplicity, we assumed that nobody was born on February 29th. This actually doesn’t change the answer much.

All right, first, note that birthdays can be represented as numbers between 1 and 365. So a sample of 50 random birthdays can be obtained simply using the sample function, like this. To check if, in this particular set of 50 people we have at least two with the same birthday, we can use the function duplicated, which returns true whenever an element of a vector has already appeared in that vector. So here’s an example. If I type duplicated 1, 2, 3, 1, 4, 3, 5, , we get true’s for the 1 and the 3 the second time they appear. So to check if two birthdays were the same, we simply use any and duplicated functions, like this. And in the case that we just generated, we actually do have this happening. We did have two people, at least two people, with the same birthday. We get true. Now, to estimate the probability, we’re going to repeat this experiment. We’re going to run a Monte Carlo simulation over and over again.

So what we do is we do it 10,000 times. We use the replicate function like this. And when we’re done, we get that the probability of having two people, at least two people, with the same birthday in a group of 50 people is about 98%. Were you expecting this to be so high? People tend to underestimate these probabilities, so [][it might be an opportunity for you to bet and make some money off of your friends] (key point of this course, please keep in mind). To get an intuition as to why this is so high, think of what happens as you get close to 365 people. At this stage, we run out of days, and the probability is 1. In the next video, we’re going to actually compute this probability for different group sizes and see how fast it gets close to 1.

[][Textbook link]

Here is a link to the textbook section on the birthday problem External link. https://rafalab.github.io/dsbook/probability.html#birthday-problem

[][Key points]

duplicated() takes a vector and returns a vector of the same length with TRUE for any elements that have appeared previously in that vector.
We can compute the probability of shared birthdays in a group of people by modeling birthdays as random draws from the numbers 1 through 365. We can then use this sampling model of birthdays to run a Monte Carlo simulation to estimate the probability of shared birthdays.

Code: The birthday problem

checking for duplicated bdays in one 50 person group

n <- 50 bdays <- sample(1:365, n, replace = TRUE) # generate n random birthdays any(duplicated(bdays)) # check if any birthdays are duplicated

Monte Carlo simulation with B=10000 replicates

B <- 10000 results <- replicate(B, { # returns vector of B logical values bdays <- sample(1:365, n, replace = TRUE) any(duplicated(bdays)) }) mean(results) # calculates proportion of groups with duplicated bdays

birthdays <- sample(1:365, 50, replace = T)

length(unique(birthdays))      # So we do have the same birthday classmates in a 50 sized class, should repeat it many times and simulate the %
## [1] 44
mean(birthdays %in% unique(birthdays))
## [1] 1
birthdaycheck <- replicate(100000, {
  same <- sample(365, 50, replace = T)
  50 - length(unique(same)) >=1             # I haven't learn the course, did I doing it wrong or something?  Why its so high ???
})


mean(birthdaycheck)
## [1] 0.9706

sapply

Say you want to use what you’ve just learned about the birthday problem to bet with friends about two people having the same birthday in a group of people. [][When are the chances larger than 50%? Larger than 75%? ] Let’s create a lookup table. We can quickly create a function to compute this for any group. We write the function like this. We’ll call it compute prob, and we’ll basically make the calculations for the probability of two people having the same birthday. We will use a small Monte Carlo simulation to do it. Now that we’ve done this, we want to compute this function, we want to apply this function to several values of n, let’s say from 1 to 60.

Let’s define n as a sequence starting at 1 and ending at 60. Now, we can use a for loop to apply this function to each value in n, but it turns out that for loops are rarely the preferred approach in R. In general, we try to perform operations on entire vectors. Arithmetic operations, for example, operate on vectors in an element wise fashion. We saw this when we learned about R. So if we type x equals 1 through 10, now X is the vector starting at 1 and ending at 10, and we compute the square root of x, it actually computes the square root for each element.

Equally, if we define y to be 1 through 10, and then multiply x by y, it multiplies each element 1 by 1–1 times 1, 2 times 2, et cetera. So there’s really no need for for loops. [][But not all functions work this way]. You can’t just send a vector to any function in R. For example, the function we just wrote does not work element-wise since it’s expecting a scalar, it’s expecting an n. This piece of code does not do what we want. If we type compute prob and send it the vector n, we will not get what we want. We will get just one number. What we can do instead is use the function sapply(). sapply permits us to perform element-wise operations on any function. Here’s how it works. We’ll define a simple example for the vector 1 through 10. If we want to apply the square roots of each element of x, we can simply type sapply x comma square root, and it’ll apply square root to each element of x. Of course, we don’t need to do this because square root already does that, but we are using it as a simple example. So for our case, we can simply type prob equals sapply n– n is our vector–and then the function we define compute prob.

And this will assign to each element of prob the probability of two people having the same birthday for that n. And now we can very quickly make a plot. We plot the probability of two people having the same birthday against the size of the group. Now, let’s compute the exact probabilities rather than use Monte Carlo simulations. The function we just defined uses a Monte Carlo simulation, but we can use what we’ve learned about probability theory to compute the exact value. Not only do we get the exact answer using math, but the computations are much faster since we don’t have to generate experiments. We simply get a number. To make the math simpler for this particular problem, [][instead of computing the probability of it happening, we’ll compute the probability of it not happening, and then we can use the multiplication rule].

==============You need to break your thought to tensor level, and pushing it forward one by one, then you’ll have the solution ============== Let’s start with the first person. The probability that person 1 has a unique birthday is 1, of course. All right. Now let’s move on to the second one. The probability that the second person has a unique birthday given that person 1 already took one of the days is 364 divided by 365. Then for a person 3, given that the first two people already have unique birthdays, that leaves 363. So now that probability is 363 divided by 365. If we continue this way and find the chances of all, say, 50 people having unique birthdays, we would multiply 1 times 364 divided by 365, times 363 divided by 365, dot dot dot, all the way to the 50th element.

Here’s the equation. Now, we can easily write a function that does this. This time we’ll call it exact prob. It takes n as a argument, and it computes this probability using this simple code. Now we can compute each probability for each n using sapply again, like this. And if we plot it, we can see that the Monte Carlo simulations were almost exactly right. They were almost exact approximations of the actual value. Now, notice had it not been possible to compute the exact probabilities, something that sometimes happens, we would have still been able to accurately estimate the probabilities using Monte Carlo.

[][Textbook links] The textbook discussion of the basics of sapply() can be found in this textbook section External link. https://rafalab.github.io/dsbook/programming-basics.html#vectorization The textbook discussion of sapply() for the birthday problem can be found within the birthday problem section External link. https://rafalab.github.io/dsbook/probability.html#birthday-problem

[][Key points]

Some functions automatically apply element-wise to vectors, such as sqrt() and *.
However, other functions do not operate element-wise by default. This includes functions we define ourselves.

The function sapply(x, f) allows any other function f to be applied element-wise to the vector x.

The probability of an event happening is 1 minus the probability of that event not happening:
    Pr(event) = 1 - Pr(no event)
    
We can compute the probability of shared birthdays mathematically:
    Pr(shared birthdays) = 1 - Pr(no shared birthdays) = 1 - (1 * 364/365 * 363/365 * ... * (365-n+1)/365)

Code: Function for birthday problem Monte Carlo simulations

Note that the function body of compute_prob() is the code that we wrote in the previous video. If we write this code as a function, we can use sapply() to apply this function to several values of n.

function to calculate probability of shared bdays across n people

compute_prob <- function(n, B = 10000) { same_day <- replicate(B, { bdays <- sample(1:365, n, replace = TRUE) any(duplicated(bdays)) }) mean(same_day) }

n <- seq(1, 60)

Code: Element-wise operation over vectors and sapply

x <- 1:10 sqrt(x) # sqrt operates on each element of the vector

y <- 1:10 xy # operates element-wise on both vectors

compute_prob(n) # does not iterate over the vector n without sapply

x <- 1:10 sapply(x, sqrt) # this is equivalent to sqrt(x)

prob <- sapply(n, compute_prob) # element-wise application of compute_prob to n plot(n, prob)

Code: Computing birthday problem probabilities with sapply

function for computing exact probability of shared birthdays for any n

exact_prob <- function(n){ prob_unique <- seq(365, 365-n+1)/365 # vector of fractions for mult. rule 1 - prod(prob_unique) # calculate prob of no shared birthdays and subtract from 1 }

applying function element-wise to vector of n values

eprob <- sapply(n, exact_prob)

plotting Monte Carlo results and exact probabilities on same graph

plot(n, prob) # plot Monte Carlo results lines(n, eprob, col = “red”) # add line for exact prob

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.6     v purrr   0.3.4
## v tibble  3.1.7     v dplyr   1.0.9
## v tidyr   1.2.0     v stringr 1.4.0
## v readr   2.1.2     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
compute_prob <- function(n, B = 100000){
  same_day <- replicate(B, {                # We are applying a Monte Carlo simulation, obviously we need replicate function
    bdays <- sample(1:365, n, replace = T)
    any(duplicated(bdays))
  })
  mean(same_day)
}



compute_prob(23)       # Can you believe it, I got one shoot and get the correct answer 50%
## [1] 0.50619
                       # The power of replacement, how interesting ???
# ===============================================================================================================================
# Get prepared, womeday we may need to write a R function for later use



# ===============================================================================================================================
n <- seq(1, 30)

sapply(n, compute_prob)   # =========================================================================================================
##  [1] 0.00000 0.00256 0.00825 0.01695 0.02719 0.04139 0.05562 0.07353 0.09642
## [10] 0.11613 0.14081 0.16415 0.19438 0.22401 0.25248 0.28394 0.31512 0.34712
## [19] 0.37605 0.41005 0.44442 0.47577 0.50685 0.53867 0.57103 0.60034 0.62618
## [28] 0.65568 0.68057 0.70642
plot(sapply(n, compute_prob))

exact_prob <- function(n){                # =============================================================================================
  prob_unique <- seq(365, 365-n+1)/365    # What does this line of code doing ???
  1 - prod(prob_unique)       # prod stands for product calculation
}


exact_prob(23)
## [1] 0.5072972
eprob <- sapply(60, exact_prob)           # Using sappy() a sequence with defined function, but inside the function, seq() already did element wise 
                                          # ========================================================================================================
eprob
## [1] 0.9941227
ff <- seq(365, 300)


ff
##  [1] 365 364 363 362 361 360 359 358 357 356 355 354 353 352 351 350 349 348 347
## [20] 346 345 344 343 342 341 340 339 338 337 336 335 334 333 332 331 330 329 328
## [39] 327 326 325 324 323 322 321 320 319 318 317 316 315 314 313 312 311 310 309
## [58] 308 307 306 305 304 303 302 301 300
n <- seq(1: 60)      # ==================================================================================================================



prob <- sapply(n, compute_prob)       ##############


exact_prob <- function(n){                # =============================================================================================
  prob_unique <- seq(365, 365-n+1)/365    # What does this line of code doing ???
  1 - prod(prob_unique)       # prod stands for product calculation
}



eprob <- sapply(n, exact_prob)         ##############


plot(n, prob) 
lines(n, eprob, col = "red")

This image ment to be here

On any function

break thought into tensors and approaching the solution.png

Now you must can understand this, this is the bridge

How Many Monte Carlo Experiments are Enough?

In the examples we have seen, we have used 10,000 Monte Carlo experiments. It turns out that this provided very accurate estimates for the examples we looked at. In more complex calculations, 10,000 may not nearly be enough. Also for some calculations, 10,000 experiments might not be computationally feasible, and it might be more than we need. In practice, we won’t know what the answer is, so we don’t know if our Monte Carlo estimate is accurate.

We know that the larger the number of experiments, we’ve been using the letter B to represent that, the better the approximation. But how big do we need it to be? This is actually a challenging question, and answering it often requires advanced theoretical statistics training. One practical approach we will describe here is to check for the stability of the estimate. Here’s an example with the birthday problem. We’re going to use n equals 22. There’s 22 people. So we’re going to run a simulation where we compute or estimate the probability of two people having a certain birthday using different sizes of the Monte Carlo simulations. So the value of b going to go from 10, to 20, to 40, to 100, et cetera. We compute the simulation, and now we look at the values that we get for each simulation.

Remember, each simulation has a different b, a different number of experiments. When we see this graph, we can see that it’s wiggling up and down. That’s because the estimate is not stable yet. It’s not such a great estimate. But as b gets bigger and bigger, eventually it starts to stabilize. And that’s when we start getting a feeling for the fact that now perhaps we have a large enough number of experiments.

[][Textbook link]

Here is a link to the matching textbook section External link. https://rafalab.github.io/dsbook/probability.html#infinity-in-practice

[][Key points]

The larger the number of Monte Carlo replicates , the more accurate the estimate.
Determining the appropriate size for can require advanced statistics.
One practical approach is to try many sizes for and look for sizes that provide stable estimates.

Code: Estimating a practical value of B

This code runs Monte Carlo simulations to estimate the probability of shared birthdays using several B values and plots the results. When B is large enough that the estimated probability stays stable, then we have selected a useful value of B.

B <- 10^seq(1, 5, len = 100) # defines vector of many B values compute_prob <- function(B, n = 22){ # function to run Monte Carlo simulation with each B same_day <- replicate(B, { bdays <- sample(1:365, n, replace = TRUE) any(duplicated(bdays)) }) mean(same_day) }

prob <- sapply(B, compute_prob) # apply compute_prob to many values of B plot(log10(B), prob, type = “l”) # plot a line graph of estimates

B <- 10^seq(1, 5, len=100)

compute_prob22 <- function(B, n=22){
  same_day <- replicate(B, {
    bdays <- sample(365, n, replace = T)
    any(duplicated(bdays))
  })
  mean(same_day)
}


prob22 <- sapply(B, compute_prob22)
prob22
##   [1] 0.4000000 0.3000000 0.5000000 0.3076923 0.2857143 0.4666667 0.4117647
##   [8] 0.3157895 0.3809524 0.2608696 0.4800000 0.5555556 0.5000000 0.4242424
##  [15] 0.5000000 0.4500000 0.5681818 0.5416667 0.5471698 0.5000000 0.5312500
##  [22] 0.4142857 0.4805195 0.5119048 0.5591398 0.4607843 0.3928571 0.4390244
##  [29] 0.4518519 0.4932432 0.4753086 0.4662921 0.4744898 0.4697674 0.5169492
##  [36] 0.4324324 0.4471831 0.4679487 0.4723032 0.5132979 0.4600484 0.4503311
##  [43] 0.4486922 0.4670330 0.4557596 0.4870624 0.4612188 0.4747475 0.4856157
##  [50] 0.4821803 0.4718243 0.4638816 0.4686757 0.4804913 0.4687294 0.4814149
##  [57] 0.4715847 0.5121951 0.4689342 0.4925620 0.4653614 0.4665523 0.4785871
##  [64] 0.4793506 0.4640540 0.4804918 0.4768369 0.4648606 0.4824687 0.4792176
##  [71] 0.4830710 0.4646820 0.4758969 0.4769715 0.4794268 0.4662376 0.4812203
##  [78] 0.4891212 0.4666996 0.4802648 0.4798219 0.4709681 0.4733771 0.4826318
##  [85] 0.4772305 0.4775428 0.4783148 0.4743014 0.4739551 0.4757872 0.4801211
##  [92] 0.4714995 0.4760836 0.4742499 0.4764179 0.4789194 0.4788356 0.4729044
##  [99] 0.4749440 0.4771900
hist(prob22)

plot(log10(B), prob22)

This is actually a challenging question, and answering it often requires advanced theoretical statistics training.

DataCamp Assessment: Combinations and Permutations

Assessment due Jun 15, 2022 10:43 AWST

This assessment covers combinations and permutations.

By clicking OK, you agree to DataCamp’s privacy policy: https://www.datacamp.com/privacy-policy. Note that you might need to disable your pop-up blocker, or allow “www.datacamp.com” in your pop-up blocker allowed list. When you have completed the exercises, return to edX to continue your learning. Assessment: Combinations and permutations (External resource) (5.0 points possible) By clicking OK, you agree to DataCamp’s privacy policy: https://www.datacamp.com/privacy-policy.

Exercise 1. Independence

Imagine you draw two balls from a box containing colored balls. You either replace the first ball before you draw the second or you leave the first ball out of the box when you draw the second ball.

Under which situation are the two draws independent of one another?

Remember that two events A and B are independent if Pr(A and B) = Pr(A) * P(B). Instructions 50 XP Possible Answers

You don't replace the first ball before drawing the next.
You do replace the first ball before drawing the next.
Neither situation describes independent events.
Both situations describe independent events.

Exercise 2. Sampling with replacement

Say you’ve drawn 5 balls from the a box that has 3 cyan balls, 5 magenta balls, and 7 yellow balls, with replacement, and all have been yellow.

What is the probability that the next one is yellow? Instructions 100 XP

Assign the variable p_yellow as the probability of choosing a yellow ball on the first draw.
Using the variable p_yellow, calculate the probability of choosing a yellow ball on the sixth draw.

Below are my solutions

cyan <- 3
magenta <- 5
yellow <- 7

# Assign the variable 'p_yellow' as the probability that a yellow ball is drawn from the box.
p_yellow <- yellow/(cyan + magenta + yellow)
p_yellow
## [1] 0.4666667
# Using the variable 'p_yellow', calculate the probability of drawing a yellow ball on the sixth draw. Print this value to the console.
p_yellow6 <- (1 - p_yellow)^5 * p_yellow        # Those are my imagination, figured what does the question ask for first
p_yellow6
## [1] 0.02013726

Incorrect submission

You are not providing a calculation that gives the correct answer. The probability of choosing a yellow ball does not depend on subsequent draws when balls are replaced after each draw.

Exercise 3. Rolling a die

If you roll a 6-sided die once, what is the probability of not seeing a 6? If you roll a 6-sided die six times, what is the probability of not seeing a 6 on any of those rolls? Instructions 100 XP

Assign the variable p_no6 as the probability of not seeing a 6 on a single roll.
Then, calculate the probability of not seeing a 6 on six rolls using p_no6.
# Assign the variable 'p_no6' as the probability of not seeing a 6 on a single roll.
p_no6 <- 1/6

# Calculate the probability of not seeing a 6 on six rolls using `p_no6`. Print your result to the console: do not assign it to a variable.
1- p_no6
## [1] 0.8333333

Incorrect submission

Make sure that you use p_no6 as your variable name for the probability of rolling any number other than six on a 6-sided die.

Incorrect submission

You are not providing a calculation that gives the correct answer. The probability of rolling any number other than a six does not change from roll to roll.

# Assign the variable 'p_no6' as the probability of not seeing a 6 on a single roll.
p_no6 <- 5/6

# Calculate the probability of not seeing a 6 on six rolls using `p_no6`. Print your result to the console: do not assign it to a variable.
1 - p_no6
## [1] 0.1666667
# Assign the variable 'p_no6' as the probability of not seeing a 6 on a single roll.
p_no6 <- 5/6

# Calculate the probability of not seeing a 6 on six rolls using `p_no6`. Print your result to the console: do not assign it to a variable.
p_no6
## [1] 0.8333333
# Assign the variable 'p_no6' as the probability of not seeing a 6 on a single roll.
p_no6 <- 5/6

# Calculate the probability of not seeing a 6 on six rolls using `p_no6`. Print your result to the console: do not assign it to a variable.
p_no6^6
## [1] 0.334898

Its a problem with carefully read the silly question instead of training your statistics knowledge and etc

Exercise 4. Probability the Celtics win a game

Two teams, say the Celtics and the Cavs, are playing a seven game series. The Cavs are a better team and have a 60% chance of winning each game.

What is the probability that the Celtics win at least one game? Remember that the Celtics must win one of the first four games, or the series will be over! Instructions 100 XP

Calculate the probability that the Cavs will win the first four games of the series.
Calculate the probability that the Celtics win at least one game in the first four games of the series.
# Assign the variable `p_cavs_win4` as the probability that the Cavs will win the first four games of the series.
p_cavs_win4 <- (0.6)^4

# Using the variable `p_cavs_win4`, calculate the probability that the Celtics win at least one game in the first four games of the series.
1 - p_cavs_win4
## [1] 0.8704

Exercise 5. Monte Carlo simulation for Celtics winning a game

Create a Monte Carlo simulation to confirm your answer to the previous problem by estimating how frequently the Celtics win at least 1 of 4 games. Use B <- 10000 simulations.

The provided sample code simulates a single series of four random games, simulated_games. Instructions 100 XP

Use the replicate function for B <- 10000 simulations of a four game series. The results of replicate should be stored to a variable named celtic_wins.
Within each simulation, replicate the sample code to simulate a four-game series named simulated_games. Then, use the any function to indicate whether the four-game series contains at least one win for the Celtics. Perform these operations in two separate steps.
Use the mean function on celtic_wins to find the proportion of simulations that contain at least one win for the Celtics out of four games.

This is wrong code

# This line of example code simulates four independent random games where the Celtics either lose or win. Copy this example code to use within the `replicate` function.
simulated_games <- sample(c("lose","win"), 4, replace = TRUE, prob = c(0.6, 0.4))

# The variable 'B' specifies the number of times we want the simulation to run. Let's run the Monte Carlo simulation 10,000 times.
B <- 10000

# Use the `set.seed` function to make sure your answer matches the expected result after random sampling.
set.seed(1)

# Create an object called `celtic_wins` that replicates two steps for B iterations: (1) generating a random four-game series `simulated_games` using the example code, then (2) determining whether the simulated series contains at least one win for the Celtics.

celtic_wins <- replicate(B, {
    simulated_games <- sample(c("lose","win"), 4, replace = TRUE, prob = c(0.6, 0.4))
    any(duplicated(simulated_games))
})



# Calculate the frequency out of B iterations that the Celtics won at least one game. Print your answer to the console.
mean(celtic_wins)
## [1] 1

This should be the correct one

# This line of example code simulates four independent random games where the Celtics either lose or win. Copy this example code to use within the `replicate` function.
simulated_games <- sample(c("lose","win"), 4, replace = TRUE, prob = c(0.6, 0.4))

# The variable 'B' specifies the number of times we want the simulation to run. Let's run the Monte Carlo simulation 10,000 times.
B <- 10000

# Use the `set.seed` function to make sure your answer matches the expected result after random sampling.
set.seed(1)

# Create an object called `celtic_wins` that replicates two steps for B iterations: (1) generating a random four-game series `simulated_games` using the example code, then (2) determining whether the simulated series contains at least one win for the Celtics.

celtic_wins <- replicate(B, {
    simulated_games <- sample(c("lose","win"), 4, replace = TRUE, prob = c(0.6, 0.4))
    any(simulated_games %in% "win")
})



# Calculate the frequency out of B iterations that the Celtics won at least one game. Print your answer to the console.
mean(celtic_wins)
## [1] 0.8757

End of Assessment: Independence and Multiplication Rule

This is the end of the programming assignment for this section. Please DO NOT click through to additional assessments from this page. Please DO answer the question on this page. If you do click through, your scores may NOT be recorded.

Click on “Awesome” to get the “points” for this question and then return to the course on edX.

You can close this window and return to Data Science: Probability. Answer the question 50XP Possible Answers

Awesome
press
1
Nope
press
2

Course / Section 1: Discrete Probability / 1.3 Addition Rule and Monty Hall

The Addition Rule

Earlier, we showed you how to compute the probability of a natural 21 in blackjack. This is getting a face card and an ace in your first draw. Here, we’re going to show you the [][addition rule], which gives you another way to compute this probability. The addition rule tells us that the probability of A or B, right, we’re going to have to make this calculation now, because [][you can get to 21 in two ways. You can get either a face card and then an ace. Or you can get an ace and then a face card]. So we’re asking what’s the probability of that or? A or B? The addition rule tells us the probability of A or B is the probability of A plus the probability a B minus the probability of A and B.

To understand why this makes sense, [][think of a Venn diagram]. If we’re computing the probability of this whole thing happening, A or B, we can add the blue circle plus the pink circle, and then subtract the middle because we have added it twice by adding the blue plus the pink. So it makes sense– the addition rule makes a lot of sense. So now let’s apply it to the natural 21. In the case of natural 21, the intersection is empty. Since both hands can’t happen, you can’t have both an ace and then a face card, and then at the same time have a face card and then an ace. Those two things can’t happen at the same time. So this will be a very easy application of the addition rule. The probability of an ace followed by a face card we know is 1 over 13 times 16 divided by 51. And the probability of a face card followed by an ace is 16 over 52 times 4 over 51. These are actually the same, which makes sense due to symmetry.

These two values are actually the same. In any case, we get the same result that we got before for the natural 21, which is about 0.05.

[][Textbook link]

Here is a link to the textbook section on the addition rule External link. https://rafalab.github.io/dsbook/probability.html#addition-rule

[][Clarification]

By “facecard”, the professor means a card with a value of 10 (K, Q, J, 10). Key points

[][** The addition rule states that the probability of event A or event B happening is the probability of event A plus the probability of event B minus the probability of both events A and B happening together.**] [][** Pr(A or B) = Pr(A) + Pr(B) - Pr(A and B)**]

[][* Note that (A or B) is equivalent to (A | B).*] ========================================================================================

Example: The addition rule for a natural 21 in blackjack

[][We apply the addition rule where A = drawing an ace then a facecard and B = drawing a facecard then an ace. Note that in this case, both events A and B cannot happen at the same time, so Pr(A and B) = 0]

    Pr(aces then faced cards) = 4/52 * 16/51                 ------------> Pr(B|A)
    pr(faced cards then aces) = 16/52 * 4/51                 ------------> Pr(A|B)
    Pr(aces then faced cards | faced cards then aces) = 4/51 * 16/51 * 16/52 * 4/51 = 0.0483.

**

this gives you another to compute the natural 21 in blackjack card game

if we compute this whole thing happening, a or b

1/13 * 16/51
## [1] 0.02413273
16/52 * 4/51
## [1] 0.02413273

The Monty Hall Problem

We’re going to look at one last example from discrete probability. It’s the Monty Hall problem. In the 1970s, there was a game show called Let’s Make A Deal. Monty Hall was the host. This is where the name of the problem comes from. At some point in the game, contestants were asked to pick one of three doors. Behind one door there was a prize. The other two had a goat behind them. And this basically meant that you lost. Monty Hall would open one of the two remaining doors and show the contestant that there was no prize behind that door. So you’re left with two doors– the one you picked, and one door that you do not know what’s behind it. So then, Monty Hall would ask, do you want to switch doors?

What would you do? We can use probability to show that if you stick to the original door, your chances of winning a car, or whatever big prize, is 1 in 3. But if you switch, your chances double to 2 in 3. This seems counterintuitive. Many people incorrectly think both chances are 1 in 2 since there’s only two doors left, and there’s a prize behind one of them. You can find detailed explanations– we’re going to provide links of the mathematics of how you can calculate that this is in fact wrong, that you have a higher chance if you switch. [][But here, we’re going to use a Monte Carlo simulation to show you that this is the case. And this will help you understand how it all works].

Note that the code we’re going to show you is longer than it needs to be. But we’re using it as an illustration to help you understand the logic behind what actually happens here. So let’s start by creating a simulation that imitates the strategy of sticking to the same door. Let’s go through the code. We’re going to do 10,000 experiments. We’re going to do this over and over 10,000 times. First thing we do, is we assign the prize to a door. All right, so the prize is going to be in one of the three doors that we have created. Then, that’s going to be in prize door. Prize door contains the number of the door with the prize behind it. Then, we’re going to imitate your pick by taking a random sample of these three doors. Now, in the next step, we’re going to decide which door you’re shown. You’re going to be shown–not your door and not the door with the prize. You’re going to be shown the other one. You stick to your door, that’s what you stick to, nothing changed. All this that we did right above doesn’t matter because you’re sticking to your door. So now we do this over and over again, and at the end (Its actually not at the end, its at the end of each simulation, so we will get a boolean value of each simulation 10000 times), we ask, is the door you chose the one you stuck to? Is that the prize door? How often does this happen?

We know it’s going to be a third, because none of this procedure changed anything. You started picking one out of three, nothing changed, and now you are asked, is the one I picked the door? If we run the simulation, we actually see it happening. We ran it 10,000 times and the probability of winning was 0.3357, about 1 in 3. Now let’s repeat the exercise, but consider the switch strategy. We start the same way. We have three doors, we assign three prizes at random. Then we know which one has the good prize, the car, but we don’t tell the contestant. So the contestant has to pick one. It’s basically a random pick. That’s what my pick is. And now we’re going to show the contestant one door. It can’t be the one they chose, and it can’t be the one with the car. So, that only leaves one door– the door with nothing behind it that was not chosen. So now what you’re going to do is you’re going to switch. You’re going to switch to the door that they didn’t show you, because the one that they did show you had nothing behind it. So basically, what’s happening is you are switching from the original that had a 1 in 3 chance of being the one to whatever is the other option, which has to have a 2 in 3 chance. So if we run the simulation, we actually confirm that. We get that the proportion of times a win is 0.6717 which is about 2/3. The Monte Carlo estimate confirms the two out of three calculation.

[][Textbook section]

Here is the textbook section on the Monty Hall Problem External link. https://rafalab.github.io/dsbook/probability.html#monty-hall-problem

[][Key points]

Monte Carlo simulations can be used to simulate random outcomes, which makes them useful when exploring ambiguous or less intuitive problems like the Monty Hall problem.
In the Monty Hall problem, contestants choose one of three doors that may contain a prize. Then, one of the doors that was not chosen by the contestant and does not contain a prize is revealed. The contestant can then choose whether to stick with the original choice or switch to the remaining unopened door.
Although it may seem intuitively like the contestant has a 1 in 2 chance of winning regardless of whether they stick or switch, Monte Carlo simulations demonstrate that the actual probability of winning is 1 in 3 with the stick strategy and 2 in 3 with the switch strategy.
For more on the Monty Hall problem, you can watch a detailed explanation here External link or read an explanation here External link.
https://www.khanacademy.org/math/statistics-probability/probability-library/basic-theoretical-probability/v/monty-hall-problem
https://en.wikipedia.org/wiki/Monty_Hall_problem

Code: Monte Carlo simulation of stick strategy

B <- 10000 stick <- replicate(B, { doors <- as.character(1:3) prize <- sample(c(“car”,“goat”,“goat”)) # puts prizes in random order prize_door <- doors[prize == “car”] # note which door has prize my_pick <- sample(doors, 1) # note which door is chosen show <- sample(doors[!doors %in% c(my_pick, prize_door)],1) # open door with no prize that isn’t chosen stick <- my_pick # stick with original door stick == prize_door # test whether the original door has the prize }) mean(stick) # probability of choosing prize door when sticking

Code: Monte Carlo simulation of switch strategy

switch <- replicate(B, { doors <- as.character(1:3) prize <- sample(c(“car”,“goat”,“goat”)) # puts prizes in random order prize_door <- doors[prize == “car”] # note which door has prize my_pick <- sample(doors, 1) # note which door is chosen first show <- sample(doors[!doors %in% c(my_pick, prize_door)], 1) # open door with no prize that isn’t chosen switch <- doors[!doors%in%c(my_pick, show)] # switch to the door that wasn’t chosen first or opened switch == prize_door # test whether the switched door has the prize }) mean(switch) # probability of choosing prize door when switching

Trying to understand the logic behind the below R code, next time you should be able to draft those kind to code by reading the questions =========

B <- 100000

stick <- replicate(B, {
  doors <- as.character(1:3)
  prize <- sample(c("Car", "Goat", "Goat"))
  prize_door <- doors[prize == "Car"]
  the_pick <- sample(doors, 1)
  show <- sample(doors[!doors %in% c(the_pick, prize_door)], 1)
  stick <- the_pick
  stick == prize_door
})


mean(stick)
## [1] 0.33027
switch <- replicate(B, {
  doors <- as.character(1:3)
  prize <- sample(c("Car", "Goat", "Goat"))
  prize_door <- doors[prize == "Car"]
  the_pick <- sample(doors, 1)
  show <- sample(doors[!doors %in% c(the_pick, prize_door)], 1)
  switch <- sample(doors[!doors %in% c(the_pick, show)], 1)
  switch == prize_door
})


mean(switch)
## [1] 0.66665
doors <- as.character(1:3)
doors
## [1] "1" "2" "3"
prize <- sample(c("Car", "Goat", "Goat"))
prize
## [1] "Goat" "Goat" "Car"

and show contestant that there is no prize behind that door

DataCamp Assessment: The Addition Rule and Monty Hall

Assessment due Jun 15, 2022 10:43 AWST

This assessment covers more principles of probability again looking at sports game series.

By clicking OK, you agree to DataCamp’s privacy policy: https://www.datacamp.com/privacy-policy. Note that you might need to disable your pop-up blocker, or allow “www.datacamp.com” in your pop-up blocker allowed list. When you have completed the exercises, return to edX to continue your learning. Assessment: The Addition Rule and Monty Hall (External resource) (4.5 points possible) By clicking OK, you agree to DataCamp’s privacy policy: https://www.datacamp.com/privacy-policy.

Exercise 1. The Cavs and the Warriors

Two teams, say the Cavs and the Warriors, are playing a seven game championship series. The first to win four games wins the series. The teams are equally good, so they each have a 50-50 chance of winning each game.

If the Cavs lose the first game, what is the probability that they win the series? Instructions 100 XP

Assign the number of remaining games to the variable n.
Assign a variable outcomes as a vector of possible outcomes in a single game, where 0 indicates a loss and 1 indicates a win for the Cavs.
Assign a variable l to a list of all possible outcomes in all remaining games. Use the rep function to create a list of n games, where each game consists of list(outcomes).
Use the expand.grid function to create a data frame containing all the combinations of possible outcomes of the remaining games.
Use the rowSums function to identify which combinations of game outcomes result in the Cavs winning the number of games necessary to win the series.
Use the mean function to calculate the proportion of outcomes that result in the Cavs winning the series and print your answer to the console.

My poor initial approach,

==================================================================================================================================================

# Assign a variable 'n' as the number of remaining games.
n <- 7 - 1

# Assign a variable `outcomes` as a vector of possible game outcomes, where 0 indicates a loss and 1 indicates a win for the Cavs.
outcomes <- sample(c(0, 1), 1, prob=c(0.5, 0.5), replace=T)
outcomes

# Assign a variable `l` to a list of all possible outcomes in all remaining games. Use the `rep` function on `list(outcomes)` to create list of length `n`.
l <- rep(list(outcomes), times=n)
l

# Create a data frame named 'possibilities' that contains all combinations of possible outcomes for the remaining games.
possibilities <- expand.grid(l)

# Create a vector named 'results' that indicates whether each row in the data frame 'possibilities' contains enough wins for the Cavs to win the series.
results <- 

# Calculate the proportion of 'results' in which the Cavs win the series. Print the outcome to the console.
mean(results)

Vectors are generally created using the c function.png

Hint

Any combination of 4 or more wins across the 6 remaining games allows the Cavs to win the series.
The possibilities data frame should contain one column for each remaining game.
The possibilities data frame should contain one row for each combination of wins (1) or losses (0) for the next 6 games.
results should be a logical vector.
# Assign a variable 'n' as the number of remaining games.
n <- 6

# Assign a variable `outcomes` as a vector of possible game outcomes, where 0 indicates a loss and 1 indicates a win for the Cavs.
outcomes <- c(0, 1)

# Assign a variable `l` to a list of all possible outcomes in all remaining games. Use the `rep` function on `list(outcomes)` to create list of length `n`.
l <- rep(list(outcomes), n)
l
## [[1]]
## [1] 0 1
## 
## [[2]]
## [1] 0 1
## 
## [[3]]
## [1] 0 1
## 
## [[4]]
## [1] 0 1
## 
## [[5]]
## [1] 0 1
## 
## [[6]]
## [1] 0 1
# Create a data frame named 'possibilities' that contains all combinations of possible outcomes for the remaining games.
possibilities <- expand.grid(l)
possibilities
##    Var1 Var2 Var3 Var4 Var5 Var6
## 1     0    0    0    0    0    0
## 2     1    0    0    0    0    0
## 3     0    1    0    0    0    0
## 4     1    1    0    0    0    0
## 5     0    0    1    0    0    0
## 6     1    0    1    0    0    0
## 7     0    1    1    0    0    0
## 8     1    1    1    0    0    0
## 9     0    0    0    1    0    0
## 10    1    0    0    1    0    0
## 11    0    1    0    1    0    0
## 12    1    1    0    1    0    0
## 13    0    0    1    1    0    0
## 14    1    0    1    1    0    0
## 15    0    1    1    1    0    0
## 16    1    1    1    1    0    0
## 17    0    0    0    0    1    0
## 18    1    0    0    0    1    0
## 19    0    1    0    0    1    0
## 20    1    1    0    0    1    0
## 21    0    0    1    0    1    0
## 22    1    0    1    0    1    0
## 23    0    1    1    0    1    0
## 24    1    1    1    0    1    0
## 25    0    0    0    1    1    0
## 26    1    0    0    1    1    0
## 27    0    1    0    1    1    0
## 28    1    1    0    1    1    0
## 29    0    0    1    1    1    0
## 30    1    0    1    1    1    0
## 31    0    1    1    1    1    0
## 32    1    1    1    1    1    0
## 33    0    0    0    0    0    1
## 34    1    0    0    0    0    1
## 35    0    1    0    0    0    1
## 36    1    1    0    0    0    1
## 37    0    0    1    0    0    1
## 38    1    0    1    0    0    1
## 39    0    1    1    0    0    1
## 40    1    1    1    0    0    1
## 41    0    0    0    1    0    1
## 42    1    0    0    1    0    1
## 43    0    1    0    1    0    1
## 44    1    1    0    1    0    1
## 45    0    0    1    1    0    1
## 46    1    0    1    1    0    1
## 47    0    1    1    1    0    1
## 48    1    1    1    1    0    1
## 49    0    0    0    0    1    1
## 50    1    0    0    0    1    1
## 51    0    1    0    0    1    1
## 52    1    1    0    0    1    1
## 53    0    0    1    0    1    1
## 54    1    0    1    0    1    1
## 55    0    1    1    0    1    1
## 56    1    1    1    0    1    1
## 57    0    0    0    1    1    1
## 58    1    0    0    1    1    1
## 59    0    1    0    1    1    1
## 60    1    1    0    1    1    1
## 61    0    0    1    1    1    1
## 62    1    0    1    1    1    1
## 63    0    1    1    1    1    1
## 64    1    1    1    1    1    1
# Create a vector named 'results' that indicates whether each row in the data frame 'possibilities' contains enough wins for the Cavs to win the series.
results <- rowSums(possibilities) >= 4
results
##  [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
## [13] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
## [25] FALSE FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE
## [37] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE
## [49] FALSE FALSE FALSE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE
## [61]  TRUE  TRUE  TRUE  TRUE
# Calculate the proportion of 'results' in which the Cavs win the series. Print the outcome to the console.
mean(results)
## [1] 0.34375

Exercise 2. The Cavs and the Warriors - Monte Carlo

Confirm the results of the previous question with a Monte Carlo simulation to estimate the probability of the Cavs winning the series after losing the first game. Instructions 100 XP

Use the replicate function to replicate the sample code for B <- 10000 simulations.
Use the sample function to simulate a series of 6 games with random, independent outcomes of either a loss for the Cavs (0) or a win for the Cavs (1) in that order. Use the default probabilities to sample.
Use the sum function to determine whether a simulated series contained at least 4 wins for the Cavs.
Use the mean function to find the proportion of simulations in which the Cavs win at least 4 of the remaining games. Print your answer to the console.

Thank god, got corrected with one shoot

# The variable `B` specifies the number of times we want the simulation to run. Let's run the Monte Carlo simulation 10,000 times.
B <- 10000

# Use the `set.seed` function to make sure your answer matches the expected result after random sampling.
set.seed(1)

# Create an object called `results` that replicates for `B` iterations a simulated series and determines whether that series contains at least four wins for the Cavs.
results <- replicate(B, {
    sum(sample(c(0, 1), 6, replace=T)) >= 4
})



# Calculate the frequency out of `B` iterations that the Cavs won at least four games in the remainder of the series. Print your answer to the console.
mean(results)
## [1] 0.3453

Exercise 3. A and B play a series - part 1

Two teams, A and B, are playing a seven series game series. Team A is better than team B and has a p>0.5 chance of winning each game. Instructions 100 XP

Use the function `sapply()` to compute the probability, call it `Pr` of winning for `p <- seq(0.5, 0.95, 0.025)`.
Then plot the result plot(p, Pr).

Thank god, got one shoot again

# Let's assign the variable 'p' as the vector of probabilities that team A will win.
p <- seq(0.5, 0.95, 0.025)

# Given a value 'p', the probability of winning the series for the underdog team B can be computed with the following function based on a Monte Carlo simulation:
prob_win <- function(p){
  B <- 10000
  result <- replicate(B, {
    b_win <- sample(c(1,0), 7, replace = TRUE, prob = c(1-p, p))
    sum(b_win)>=4
    })
  mean(result)
}

# Apply the 'prob_win' function across the vector of probabilities that team A will win to determine the probability that team B will win. Call this object 'Pr'.
Pr <- sapply(p, prob_win)

# Plot the probability 'p' on the x-axis and 'Pr' on the y-axis.
plot(p, Pr) 

Exercise 4. A and B play a series - part 2

Repeat the previous exercise, but now keep the probability that team

wins fixed at p <- 0.75 and compute the probability for different series lengths. For example, wins in best of 1 game, 3 games, 5 games, and so on through a series that lasts 25 games. Instructions 100 XP

Use the seq function to generate a list of odd numbers ranging from 1 to 25.
Use the function sapply to compute the probability, call it Pr, of winning during series of different lengths.
Then plot the result plot(N, Pr).

Lets see how to construct a R solution based on the statistic thinking framework we trained

# Given a value 'p', the probability of winning the series for the underdog team B can be computed with the following function based on a Monte Carlo simulation:
prob_win <- function(N, p=0.75){
      B <- 10000
      result <- replicate(B, {
        b_win <- sample(c(1,0), N, replace = TRUE, prob = c(1-p, p))
        sum(b_win)>=(N+1)/2
        })
      mean(result)
    }

# Assign the variable 'N' as the vector of series lengths. Use only odd numbers ranging from 1 to 25 games.
N <- seq(1,25, 2)
N
##  [1]  1  3  5  7  9 11 13 15 17 19 21 23 25
# Apply the 'prob_win' function across the vector of series lengths to determine the probability that team B will win. Call this object `Pr`.
Pr <- sapply(N, prob_win)
Pr
##  [1] 0.2425 0.1589 0.1034 0.0741 0.0496 0.0352 0.0247 0.0160 0.0111 0.0093
## [11] 0.0063 0.0051 0.0022
# Plot the number of games in the series 'N' on the x-axis and 'Pr' on the y-axis.
plot(N, Pr)

End of Assessment: The Addition Rule

This is the end of the programming assignment for this section. Please DO NOT click through to additional assessments from this page. Please DO answer the question on this page. If you do click through, your scores may NOT be recorded.

Click on “Awesome” to get the “points” for this question and then return to the course on edX.

You can close this window and return to Data Science: Probability. Answer the question 50XP Possible Answers

Awesome
press
1
Nope
press
2

Course / Section 1: Discrete Probability / 1.4 Assessment: Discrete Probability

Introduction

The following assessments allow you to practice the probability and coding skills you’ve learned in Section 1: Discrete Probability. You will likely find it useful to try out code to answer the problems using R on your own machine.

You will benefit from using the following libraries:

library(gtools) library(tidyverse)

library(gtools)
library(tidyverse)

Question 1: Olympic running

Assessment due Jun 15, 2022 10:43 AWST

In the 200m dash finals in the Olympics, 8 runners compete for 3 medals (order matters). In the 2012 Olympics, 3 of the 8 runners were from Jamaica and the other 5 were from different countries. The three medals were all won by Jamaica (Usain Bolt, Yohan Blake, and Warren Weir).

Use the information above to help you answer the following four questions.

Question 1a

1/1 point (graded) How many different ways can the 3 medals be distributed across 8 runners? correct

336 Loading

Explanation

The following code can be used to determine the number of permutations:

      library(gtools)

medals <- permutations(8,3) nrow(medals)

You have used 2 of 10 attempts

The thing is how can we understand this statistic case based on what we learned in the previous card game? Does this makes sense to us????

=============================================================================================================================

library(gtools)
library(tidyverse)


prizes <- c("Gold", "Silver", "Bronze") 
runners <- c("Runner_01", "Runner_02", "Runner_03", "Runner_04", "Runner_05", "Runner_06", "Runner_07", "Runner_08")


# Use your brain to think about this condition and the card game?  Why we shouldn't apple same process here???
# ===============================================================================================================================
prob <- expand.grid(prize = prizes, runner = runners)

cases <- paste(prob$prize, prob$runner)


outcomes <- permutations(8, 3, v=runners)
#outcomes
length(outcomes[, 1])
## [1] 336

Question 1b

1/1 point (graded) How many different ways can the three medals be distributed among the 3 runners from Jamaica? correct

6 Loading

Explanation

The following code can be used to determine the number of permutations:

      jamaica < permutations(3,3)

nrow(jamaica)

You have used 1 of 10 attempts

Below is my own approach, withought reading the solution

library(gtools)

suits <- c("Diamonds", "Clubs", "Hearts", "Spades")
numbers <- c("Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King")


deck <- expand.grid(suit = suits, number = numbers)
deck <- paste(deck$suit, deck$number)
deck
##  [1] "Diamonds Ace"   "Clubs Ace"      "Hearts Ace"     "Spades Ace"    
##  [5] "Diamonds Deuce" "Clubs Deuce"    "Hearts Deuce"   "Spades Deuce"  
##  [9] "Diamonds Three" "Clubs Three"    "Hearts Three"   "Spades Three"  
## [13] "Diamonds Four"  "Clubs Four"     "Hearts Four"    "Spades Four"   
## [17] "Diamonds Five"  "Clubs Five"     "Hearts Five"    "Spades Five"   
## [21] "Diamonds Six"   "Clubs Six"      "Hearts Six"     "Spades Six"    
## [25] "Diamonds Seven" "Clubs Seven"    "Hearts Seven"   "Spades Seven"  
## [29] "Diamonds Eight" "Clubs Eight"    "Hearts Eight"   "Spades Eight"  
## [33] "Diamonds Nine"  "Clubs Nine"     "Hearts Nine"    "Spades Nine"   
## [37] "Diamonds Ten"   "Clubs Ten"      "Hearts Ten"     "Spades Ten"    
## [41] "Diamonds Jack"  "Clubs Jack"     "Hearts Jack"    "Spades Jack"   
## [45] "Diamonds Queen" "Clubs Queen"    "Hearts Queen"   "Spades Queen"  
## [49] "Diamonds King"  "Clubs King"     "Hearts King"    "Spades King"
hands <- permutations(52, 2, v = deck)     # ===========================================================================

length(hands[, 1])
## [1] 2652
deck
##  [1] "Diamonds Ace"   "Clubs Ace"      "Hearts Ace"     "Spades Ace"    
##  [5] "Diamonds Deuce" "Clubs Deuce"    "Hearts Deuce"   "Spades Deuce"  
##  [9] "Diamonds Three" "Clubs Three"    "Hearts Three"   "Spades Three"  
## [13] "Diamonds Four"  "Clubs Four"     "Hearts Four"    "Spades Four"   
## [17] "Diamonds Five"  "Clubs Five"     "Hearts Five"    "Spades Five"   
## [21] "Diamonds Six"   "Clubs Six"      "Hearts Six"     "Spades Six"    
## [25] "Diamonds Seven" "Clubs Seven"    "Hearts Seven"   "Spades Seven"  
## [29] "Diamonds Eight" "Clubs Eight"    "Hearts Eight"   "Spades Eight"  
## [33] "Diamonds Nine"  "Clubs Nine"     "Hearts Nine"    "Spades Nine"   
## [37] "Diamonds Ten"   "Clubs Ten"      "Hearts Ten"     "Spades Ten"    
## [41] "Diamonds Jack"  "Clubs Jack"     "Hearts Jack"    "Spades Jack"   
## [45] "Diamonds Queen" "Clubs Queen"    "Hearts Queen"   "Spades Queen"  
## [49] "Diamonds King"  "Clubs King"     "Hearts King"    "Spades King"

Question 1c

1/1 point (graded) What is the probability that all 3 medals are won by Jamaica? correct

0.0179 Loading

Explanation

The following code can be used to determine the probability:

      nrow(jamaica)/nrow(medals)
    

You have used 1 of 10 attempts Some

Below is my own approach, withought reading the solution

library(gtools)
library(tidyverse)


prizes <- c("Gold", "Silver", "Bronze") 
runners <- c("Jamaica_01", "Jamaica_02", "Jamaica_03", "Runner_04", "Runner_05", "Runner_06", "Runner_07", "Runner_08")
jamaicas <- c("Jamaica_01", "Jamaica_02", "Jamaica_03")


# Use your brain to think about this condition and the card game?  Why we shouldn't apple same process here???
prob <- expand.grid(prize = prizes, runner = runners)

cases <- paste(prob$prize, prob$runner)


all_outcomes <- permutations(8, 3, v=runners)
jamaica_coucomes <- permutations(3, 3, v=jamaicas)
length(all_outcomes[, 1])
## [1] 336
length(jamaica_coucomes[, 1])
## [1] 6
mean(all_outcomes[, 1] %in% jamaica_coucomes & all_outcomes[, 2] %in% jamaica_coucomes & all_outcomes[, 3] %in% jamaica_coucomes)
## [1] 0.01785714

Question 1d

1/1 point (graded)

Run a Monte Carlo simulation on this vector representing the countries of the 8 runners in this race:

runners <- c(“Jamaica”, “Jamaica”, “Jamaica”, “USA”, “Ecuador”, “Netherlands”, “France”, “South Africa”)

For each iteration of the Monte Carlo simulation, within a replicate() loop, select 3 runners representing the 3 medalists and check whether they are all from Jamaica. Repeat this simulation 10,000 times. Set the seed to 1 before running the loop. Calculate the probability that all the runners are from Jamaica. correct

0.0165 Loading

Explanation

Note that your answer will differ depending on whether you are using R 3.5 or earlier (0.0165) or R 3.6 or later (0.0174) because of the way set.seed works in different versions of R.

The following code can be used to determine the probability:

      set.seed(1)

runners <- c(“Jamaica”, “Jamaica”, “Jamaica”, “USA”, “Ecuador”, “Netherlands”, “France”, “South Africa”) B <- 10000 all_jamaica <- replicate(B, { results <- sample(runners, 3) all(results == “Jamaica”) }) mean(all_jamaica)

Below is my own approach, withought reading the solution

set.seed(1, sample.kind="Rounding")
## Warning in set.seed(1, sample.kind = "Rounding"): non-uniform 'Rounding' sampler
## used
runners <- c("Jamaica", "Jamaica", "Jamaica", "USA", "Ecuador", "Netherlands", "France", "South Africa")

B <- 10000

monte_carlo <- replicate(B, {
  outcomes <- sample(runners, 3)
  outcomes[1] == "Jamaica" & outcomes[2] == "Jamaica" & outcomes[3] == "Jamaica"
})


mean(monte_carlo)
## [1] 0.0165

Question 2: Restaurant management

Assessment due Jun 15, 2022 10:43 AWST

Use the information below to answer the following five questions.

A restaurant manager wants to advertise that his lunch special offers enough choices to eat different meals every day of the year. He doesn’t think his current special actually allows that number of choices, but wants to change his special if needed to allow at least 365 choices.

A meal at the restaurant includes 1 entree, 2 sides, and 1 drink. He currently offers a choice of 1 entree from a list of 6 options, a choice of 2 different sides from a list of 6 options, and a choice of 1 drink from a list of 2 options.

Question 2a

1/1 point (graded) How many meal combinations are possible with the current menu? correct

180 Loading

Explanation

The following code can be used to determine the number of combinations:

      6 * nrow(combinations(6,2)) * 2
    

You have used 2 of 10 attempts Some

6 * 6*5 * 2
## [1] 360
all_entrees <- c("entree_1", "entree_2", "entree_3", "entree_4", "entree_5", "entree_6")
sides <- c("side_1", "side_2", "side_3", "side_4", "side_5", "side_6")
all_comb <- combinations(6, 2, v=sides)
all_comb
##       [,1]     [,2]    
##  [1,] "side_1" "side_2"
##  [2,] "side_1" "side_3"
##  [3,] "side_1" "side_4"
##  [4,] "side_1" "side_5"
##  [5,] "side_1" "side_6"
##  [6,] "side_2" "side_3"
##  [7,] "side_2" "side_4"
##  [8,] "side_2" "side_5"
##  [9,] "side_2" "side_6"
## [10,] "side_3" "side_4"
## [11,] "side_3" "side_5"
## [12,] "side_3" "side_6"
## [13,] "side_4" "side_5"
## [14,] "side_4" "side_6"
## [15,] "side_5" "side_6"
all_sides <- paste(all_comb[, 1], all_comb[, 2])
all_sides
##  [1] "side_1 side_2" "side_1 side_3" "side_1 side_4" "side_1 side_5"
##  [5] "side_1 side_6" "side_2 side_3" "side_2 side_4" "side_2 side_5"
##  [9] "side_2 side_6" "side_3 side_4" "side_3 side_5" "side_3 side_6"
## [13] "side_4 side_5" "side_4 side_6" "side_5 side_6"
all_drinks <- c("drink_1", "drink_2")


special_offers <- expand.grid(all_entrees, all_sides, all_drinks)
nrow(special_offers)
## [1] 180

Question 2b

1/1 point (graded)

The manager has one additional drink he could add to the special. How many combinations are possible if he expands his original special to 3 drink options? correct

270 Loading

Explanation

The following code can be used to determine the number of combinations:

      6 * nrow(combinations(6,2)) * 3
    

You have used 1 of 10 attempts Some

all_entrees <- c("entree_1", "entree_2", "entree_3", "entree_4", "entree_5", "entree_6")
sides <- c("side_1", "side_2", "side_3", "side_4", "side_5", "side_6")
all_comb <- combinations(6, 2, v=sides)
all_comb
##       [,1]     [,2]    
##  [1,] "side_1" "side_2"
##  [2,] "side_1" "side_3"
##  [3,] "side_1" "side_4"
##  [4,] "side_1" "side_5"
##  [5,] "side_1" "side_6"
##  [6,] "side_2" "side_3"
##  [7,] "side_2" "side_4"
##  [8,] "side_2" "side_5"
##  [9,] "side_2" "side_6"
## [10,] "side_3" "side_4"
## [11,] "side_3" "side_5"
## [12,] "side_3" "side_6"
## [13,] "side_4" "side_5"
## [14,] "side_4" "side_6"
## [15,] "side_5" "side_6"
all_sides <- paste(all_comb[, 1], all_comb[, 2])
all_sides
##  [1] "side_1 side_2" "side_1 side_3" "side_1 side_4" "side_1 side_5"
##  [5] "side_1 side_6" "side_2 side_3" "side_2 side_4" "side_2 side_5"
##  [9] "side_2 side_6" "side_3 side_4" "side_3 side_5" "side_3 side_6"
## [13] "side_4 side_5" "side_4 side_6" "side_5 side_6"
all_drinks <- c("drink_1", "drink_2", "drink_3")


special_offers <- expand.grid(all_entrees, all_sides, all_drinks)
nrow(special_offers)
## [1] 270

Question 2c

1/1 point (graded)

The manager decides to add the third drink but needs to expand the number of options. The manager would prefer not to change his menu further and wants to know if he can meet his goal by letting customers choose more sides. How many meal combinations are there if customers can choose from 6 entrees, 3 drinks, and select 3 sides from the current 6 options? correct

360 Loading

Explanation

The following code can be used to determine the number of combinations:

      6 * nrow(combinations(6,3)) * 3
    

You have used 1 of 10 attempts Some

all_entrees <- c("entree_1", "entree_2", "entree_3", "entree_4", "entree_5", "entree_6")
sides <- c("side_1", "side_2", "side_3", "side_4", "side_5", "side_6")
all_comb <- combinations(6, 3, v=sides)
all_comb
##       [,1]     [,2]     [,3]    
##  [1,] "side_1" "side_2" "side_3"
##  [2,] "side_1" "side_2" "side_4"
##  [3,] "side_1" "side_2" "side_5"
##  [4,] "side_1" "side_2" "side_6"
##  [5,] "side_1" "side_3" "side_4"
##  [6,] "side_1" "side_3" "side_5"
##  [7,] "side_1" "side_3" "side_6"
##  [8,] "side_1" "side_4" "side_5"
##  [9,] "side_1" "side_4" "side_6"
## [10,] "side_1" "side_5" "side_6"
## [11,] "side_2" "side_3" "side_4"
## [12,] "side_2" "side_3" "side_5"
## [13,] "side_2" "side_3" "side_6"
## [14,] "side_2" "side_4" "side_5"
## [15,] "side_2" "side_4" "side_6"
## [16,] "side_2" "side_5" "side_6"
## [17,] "side_3" "side_4" "side_5"
## [18,] "side_3" "side_4" "side_6"
## [19,] "side_3" "side_5" "side_6"
## [20,] "side_4" "side_5" "side_6"
all_sides <- paste(all_comb[, 1], all_comb[, 2])
all_sides
##  [1] "side_1 side_2" "side_1 side_2" "side_1 side_2" "side_1 side_2"
##  [5] "side_1 side_3" "side_1 side_3" "side_1 side_3" "side_1 side_4"
##  [9] "side_1 side_4" "side_1 side_5" "side_2 side_3" "side_2 side_3"
## [13] "side_2 side_3" "side_2 side_4" "side_2 side_4" "side_2 side_5"
## [17] "side_3 side_4" "side_3 side_4" "side_3 side_5" "side_4 side_5"
all_drinks <- c("drink_1", "drink_2", "drink_3")


special_offers <- expand.grid(all_entrees, all_sides, all_drinks)
nrow(special_offers)
## [1] 360

Question 2d

1/1 point (graded)

The manager is concerned that customers may not want 3 sides with their meal. He is willing to increase the number of entree choices instead, but if he adds too many expensive options it could eat into profits. He wants to know how many entree choices he would have to offer in order to meet his goal.

  • Write a function that takes a number of entree choices and returns the number of meal combinations possible given that number of entree options, 3 drink choices, and a selection of 2 sides from 6 options.

  • Use sapply() to apply the function to entree option counts ranging from 1 to 12. What is the minimum number of entree options required in order to generate more than 365 combinations? correct

9 Loading

Explanation

The following code can be used to determine the minimum number of entree options:

      library(tidyverse)

entree_choices <- function(x){ x * nrow(combinations(6,2)) * 3 }

combos <- sapply(1:12, entree_choices)

data.frame(entrees = 1:12, combos = combos) %>% filter(combos > 365) %>% min(.$entrees)

You have used 2 of 10 attempts Some

n <- seq(1:12)
n
##  [1]  1  2  3  4  5  6  7  8  9 10 11 12
# function to calculate probability of shared bdays across n people
my_func <- function(n) {
    all_entrees <- c(1:n)
  sides <- c("side_1", "side_2", "side_3", "side_4", "side_5", "side_6")
  all_comb <- combinations(6, 2, v=sides)
  all_sides <- paste(all_comb[, 1], all_comb[, 2])
  all_drinks <- c("drink_1", "drink_2", "drink_3")
  
  special_offers <- expand.grid(all_entrees, all_sides, all_drinks)
  nrow(special_offers)
  #mean(same_day)
}



sapply(n, my_func)
##  [1]  45  90 135 180 225 270 315 360 405 450 495 540

Question 2e

1/1 point (graded)

The manager isn’t sure he can afford to put that many entree choices on the lunch menu and thinks it would be cheaper for him to expand the number of sides. He wants to know how many sides he would have to offer to meet his goal of at least 365 combinations.

  • Write a function that takes a number of side choices and returns the number of meal combinations possible given 6 entree choices, 3 drink choices, and a selection of 2 sides from the specified number of side choices.

  • Use sapply() to apply the function to side counts ranging from 2 to 12. What is the minimum number of side options required in order to generate more than 365 combinations? correct

7 Loading

Explanation

The following code can be used to determine the minimum number of side options:

      side_choices <- function(x){

6 * nrow(combinations(x, 2)) * 3 }

combos <- sapply(2:12, side_choices)

data.frame(sides = 2:12, combos = combos) %>% filter(combos > 365) %>% min(.$sides)

You have used 1 of 10 attempts Some

n <- seq(2,12)
n
##  [1]  2  3  4  5  6  7  8  9 10 11 12
# function to calculate probability of shared bdays across n people
my_func <- function(n) {
    all_entrees <- c("side_1", "side_2", "side_3", "side_4", "side_5", "side_6")
  sides <- seq(n)
  sides
  all_comb <- combinations(n, 2, v=sides)
  all_sides <- paste(all_comb[, 1], all_comb[, 2])
  all_drinks <- c("drink_1", "drink_2", "drink_3")
  
  special_offers <- expand.grid(all_entrees, all_sides, all_drinks)
  nrow(special_offers)
  #mean(same_day)
}



sapply(n, my_func)
##  [1]   18   54  108  180  270  378  504  648  810  990 1188

Questions 3 and 4: Esophageal cancer and alcohol/tobacco use, part 1

Assessment due Jun 15, 2022 10:43 AWST

Case-control studies help determine whether certain exposures are associated with outcomes such as developing cancer. The built-in dataset esoph contains data from a case-control study in France comparing people with esophageal cancer (cases, counted in ncases) to people without esophageal cancer (controls, counted in ncontrols) that are carefully matched on a variety of demographic and medical characteristics. The study compares alcohol intake in grams per day (alcgp) and tobacco intake in grams per day (tobgp) across cases and controls grouped by age range (agegp).

The dataset is available in base R and can be called with the variable name esoph:

head(esoph)

You will be using this dataset to answer the following four multi-part questions (Questions 3-6).

You may wish to use the tidyverse package:

library(tidyverse)

The following three parts have you explore some basic characteristics of the dataset.

Each row contains one group of the experiment. Each group has a different combination of age, alcohol consumption, and tobacco consumption. The number of cancer cases and number of controls (individuals without cancer) are reported for each group.

Question 3a

1/1 point (graded) How many groups are in the study? correct

88 Loading

Explanation

You can find the number of groups using nrow(esoph). You have used 1 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
library(tidyverse)


nrow(esoph)
## [1] 88
all_cases <- esoph %>%
  filter(ncases != 0) 


all_cases <- sum(all_cases$ncases)
all_cases
## [1] 200
all_controls <- sum(esoph$ncontrols)
all_controls
## [1] 775

Question 3b

1/1 point (graded) How many cases are there?

Save this value as all_cases for later problems. correct

200 Loading

Explanation

You can find the number of cases using this code:

      all_cases <- sum(esoph$ncases)

all_cases

You have used 2 of 10 attempts Some

## Question 3c

1/1 point (graded) How many controls are there?

Save this value as all_controls for later problems. correct

Loading You have used 1 of 10 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button. Correct (1/1 point)

esoph %>% 
  mutate(n_ncases = sum(ncases),
         n_ncontrols = sum(ncontrols), 
         prob = n_ncases/(n_ncases + n_ncontrols)) %>%
  group_by(alcgp) %>%
  select(alcgp, n_ncases, n_ncontrols, prob) %>%
  unique()
## # A tibble: 4 x 4
## # Groups:   alcgp [4]
##   alcgp     n_ncases n_ncontrols  prob
##   <ord>        <dbl>       <dbl> <dbl>
## 1 0-39g/day      200         775 0.205
## 2 40-79          200         775 0.205
## 3 80-119         200         775 0.205
## 4 120+           200         775 0.205
Teams %>% 
  filter(yearID %in% 1961:2001) %>%
  mutate(Singles = (H - HR - X2B - X3B)/G, BB = BB/G, HR = HR/G) %>%
  summarize(cor(BB, HR), cor(Singles, HR), cor(BB, Singles))

Question 4a

1/1 point (graded) What is the probability that a subject in the highest alcohol consumption group is a cancer case?

Report your answer to 3 significant figures. correct

0.672 or 0.402 Loading

Explanation

You can find the probability using this code:

      esoph %>%

filter(alcgp == “120+”) %>% summarize(ncases = sum(ncases), ncontrols = sum(ncontrols)) %>% mutate(p_case = ncases / (ncases + ncontrols)) %>% pull(p_case)

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 2 of 10 attempts Some

high_alco <- esoph %>%
  filter(alcgp == "120+")


high_alco
##    agegp alcgp    tobgp ncases ncontrols
## 1  25-34  120+ 0-9g/day      0         1
## 2  25-34  120+    10-19      1         0
## 3  25-34  120+    20-29      0         1
## 4  25-34  120+      30+      0         2
## 5  35-44  120+ 0-9g/day      2         1
## 6  35-44  120+    10-19      0         3
## 7  35-44  120+    20-29      2         2
## 8  45-54  120+ 0-9g/day      4         0
## 9  45-54  120+    10-19      3         1
## 10 45-54  120+    20-29      2         1
## 11 45-54  120+      30+      4         0
## 12 55-64  120+ 0-9g/day      5         5
## 13 55-64  120+    10-19      6         1
## 14 55-64  120+    20-29      2         1
## 15 55-64  120+      30+      5         1
## 16 65-74  120+ 0-9g/day      3         1
## 17 65-74  120+    10-19      1         1
## 18 65-74  120+    20-29      1         0
## 19 65-74  120+      30+      1         0
## 20   75+  120+ 0-9g/day      2         0
## 21   75+  120+    10-19      1         0
sum(high_alco$ncases)/(sum(high_alco$ncases) + sum(high_alco$ncontrols))
## [1] 0.6716418

Question 4b

1/1 point (graded) What is the probability that a subject in the lowest alcohol consumption group is a cancer case?

Report your answer to 3 significant figures. correct

0.0699 or 0.0653 Loading

Explanation

You can find the probability using this code:

      esoph %>%

filter(alcgp == “0-39g/day”) %>% summarize(ncases = sum(ncases), ncontrols = sum(ncontrols)) %>% mutate(p_case = ncases / (ncases + ncontrols)) %>% pull(p_case)

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 3 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
low_alco <- esoph %>%
  filter(alcgp == "0-39g/day")


low_alco
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  35-44 0-39g/day 0-9g/day      0        60
## 6  35-44 0-39g/day    10-19      1        13
## 7  35-44 0-39g/day    20-29      0         7
## 8  35-44 0-39g/day      30+      0         8
## 9  45-54 0-39g/day 0-9g/day      1        45
## 10 45-54 0-39g/day    10-19      0        18
## 11 45-54 0-39g/day    20-29      0        10
## 12 45-54 0-39g/day      30+      0         4
## 13 55-64 0-39g/day 0-9g/day      2        47
## 14 55-64 0-39g/day    10-19      3        19
## 15 55-64 0-39g/day    20-29      3         9
## 16 55-64 0-39g/day      30+      4         2
## 17 65-74 0-39g/day 0-9g/day      5        43
## 18 65-74 0-39g/day    10-19      4        10
## 19 65-74 0-39g/day    20-29      2         5
## 20 65-74 0-39g/day      30+      0         2
## 21   75+ 0-39g/day 0-9g/day      1        17
## 22   75+ 0-39g/day    10-19      2         4
## 23   75+ 0-39g/day      30+      1         2
sum(low_alco$ncases)/(sum(low_alco$ncases) + sum(low_alco$ncontrols))
## [1] 0.06987952

Question 4c

1/1 point (graded) Given that a person is a case, what is the probability that they smoke 10g or more a day? correct

0.61 Loading

Explanation

You can find the probability using this code:

      tob_cases <- esoph %>%

filter(tobgp != “0-9g/day”) %>% pull(ncases) %>% sum()

tob_cases/all_cases

You have used 1 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
cas <- esoph %>%
  filter(ncases != 0)


Less10 <- cas %>%
  filter(tobgp == "0-9g/day")

Less10
##    agegp     alcgp    tobgp ncases ncontrols
## 1  35-44      120+ 0-9g/day      2         1
## 2  45-54 0-39g/day 0-9g/day      1        45
## 3  45-54     40-79 0-9g/day      6        32
## 4  45-54    80-119 0-9g/day      3        13
## 5  45-54      120+ 0-9g/day      4         0
## 6  55-64 0-39g/day 0-9g/day      2        47
## 7  55-64     40-79 0-9g/day      9        31
## 8  55-64    80-119 0-9g/day      9         9
## 9  55-64      120+ 0-9g/day      5         5
## 10 65-74 0-39g/day 0-9g/day      5        43
## 11 65-74     40-79 0-9g/day     17        17
## 12 65-74    80-119 0-9g/day      6         7
## 13 65-74      120+ 0-9g/day      3         1
## 14   75+ 0-39g/day 0-9g/day      1        17
## 15   75+     40-79 0-9g/day      2         3
## 16   75+    80-119 0-9g/day      1         0
## 17   75+      120+ 0-9g/day      2         0
1- sum(Less10$ncases)/sum(cas$ncases)
## [1] 0.61

Question 4d

1/1 point (graded) Given that a person is a control, what is the probability that they smoke 10g or more a day?

Report your answer to 3 significant figures. correct

0.423 or 0.462 Loading

Explanation

You can find the probability using this code:

      tob_controls <- esoph %>%

filter(tobgp != “0-9g/day”) %>% pull(ncontrols) %>% sum()

tob_controls/all_controls

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 2 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
to_df <- esoph %>%
  filter(ncontrols != 0) %>%
  group_by(tobgp) %>%
  mutate(NO = sum(ncontrols)) %>%
  select(tobgp, NO) %>%
  unique()

to_df
## # A tibble: 4 x 2
## # Groups:   tobgp [4]
##   tobgp       NO
##   <ord>    <dbl>
## 1 0-9g/day   447
## 2 10-19      178
## 3 20-29       99
## 4 30+         51
not10 <- to_df %>%
  filter(!tobgp %in% "0-9g/day") %>%
  pull(NO) %>%
  sum
not10
## [1] 328
not10/sum(to_df$NO)
## [1] 0.4232258

Questions 5 and 6: Esophageal cancer and alcohol/tobacco use, part 2

Assessment due Jun 15, 2022 10:43 AWST

The following four parts look at probabilities related to alcohol and tobacco consumption among the cases.

Question 5a

1.0/1.0 point (graded) For cases, what is the probability of being in the highest alcohol group? correct

0.225 Loading

Explanation

The probability can be calculated using the following code:

      high_alc_cases <- esoph %>%

filter(alcgp == “120+”) %>% pull(ncases) %>% sum()

p_case_high_alc <- high_alc_cases/all_cases p_case_high_alc

You have used 1 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
cases_alcogroup <- esoph %>%
  filter(ncases != 0) %>%
  group_by(alcgp) %>%
  mutate(n_cases = sum(ncases)) %>%
  select(alcgp, n_cases) %>%
  unique()

cases_alcogroup
## # A tibble: 4 x 2
## # Groups:   alcgp [4]
##   alcgp     n_cases
##   <ord>       <dbl>
## 1 120+           45
## 2 0-39g/day      29
## 3 40-79          75
## 4 80-119         51
cases_highalco <- cases_alcogroup %>%
  filter(alcgp == "120+")

cases_highalco$n_cases/sum(cases_alcogroup$n_cases)
## [1] 0.225
45/(45+29+75+51)
## [1] 0.225

Question 5b

1.0/1.0 point (graded) For cases, what is the probability of being in the highest tobacco group? correct

0.155 Loading

Explanation

The probability can be calculated using the following code:

      high_tob_cases <- esoph %>%

filter(tobgp == “30+”) %>% pull(ncases) %>% sum()

p_case_high_tob <- high_tob_cases/all_cases p_case_high_tob

You have used 1 of 10 attempts Some

cases_togroup <- esoph %>%
  filter(ncases != 0) %>%
  group_by(tobgp) %>%
  mutate(n_cases = sum(ncases)) %>%
  select(tobgp, n_cases) %>%
  unique()

cases_togroup
## # A tibble: 4 x 2
## # Groups:   tobgp [4]
##   tobgp    n_cases
##   <ord>      <dbl>
## 1 10-19         58
## 2 20-29         33
## 3 0-9g/day      78
## 4 30+           31
cases_highto <- cases_togroup %>%
  filter(tobgp == "30+")

cases_highto$n_cases/sum(cases_togroup$n_cases)
## [1] 0.155
31/(31+78+33+58)
## [1] 0.155

Question 5c

1.0/1.0 point (graded) For cases, what is the probability of being in the highest alcohol group and the highest tobacco group? correct

0.05 Loading

Explanation

The probability can be calculated using the following code:

      high_alc_tob_cases <- esoph %>%

filter(alcgp == “120+” & tobgp == “30+”) %>% pull(ncases) %>% sum()

p_case_high_alc_tob <- high_alc_tob_cases/all_cases p_case_high_alc_tob

You have used 2 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
cases_2group <- esoph %>%
  filter(ncases != 0) %>%
  group_by(alcgp, tobgp) %>%
  mutate(n_cases = sum(ncases)) %>%
  select(alcgp, tobgp, n_cases) %>%
  unique()

cases_2group
## # A tibble: 16 x 3
## # Groups:   alcgp, tobgp [16]
##    alcgp     tobgp    n_cases
##    <ord>     <ord>      <dbl>
##  1 120+      10-19         12
##  2 0-39g/day 10-19         10
##  3 40-79     10-19         17
##  4 40-79     20-29         15
##  5 120+      0-9g/day      16
##  6 120+      20-29          7
##  7 0-39g/day 0-9g/day       9
##  8 40-79     0-9g/day      34
##  9 40-79     30+            9
## 10 80-119    0-9g/day      19
## 11 80-119    10-19         19
## 12 80-119    20-29          6
## 13 80-119    30+            7
## 14 120+      30+           10
## 15 0-39g/day 20-29          5
## 16 0-39g/day 30+            5
both_high <- cases_2group %>%
  filter(alcgp == "120+" & tobgp == "30+")

both_high$n_cases/sum(cases_2group$n_cases)
## [1] 0.05
10/(5+5+10+7+6+19+19+9+34+9+7+16+15+17+10+12)
## [1] 0.05

Question 5d

1.0/1.0 point (graded) For cases, what is the probability of being in the highest alcohol group or the highest tobacco group? correct

0.33 Loading

Explanation

The probability can be calculated using the following code:

      p_case_either_highest <- p_case_high_alc + p_case_high_tob - p_case_high_alc_tob

p_case_either_highest

You have used 1 of 10 attempts Some

cases_2group <- esoph %>%
  filter(ncases != 0) %>%
  group_by(alcgp, tobgp) %>%
  mutate(n_cases = sum(ncases)) %>%
  select(alcgp, tobgp, n_cases) %>%
  unique()

cases_2group
## # A tibble: 16 x 3
## # Groups:   alcgp, tobgp [16]
##    alcgp     tobgp    n_cases
##    <ord>     <ord>      <dbl>
##  1 120+      10-19         12
##  2 0-39g/day 10-19         10
##  3 40-79     10-19         17
##  4 40-79     20-29         15
##  5 120+      0-9g/day      16
##  6 120+      20-29          7
##  7 0-39g/day 0-9g/day       9
##  8 40-79     0-9g/day      34
##  9 40-79     30+            9
## 10 80-119    0-9g/day      19
## 11 80-119    10-19         19
## 12 80-119    20-29          6
## 13 80-119    30+            7
## 14 120+      30+           10
## 15 0-39g/day 20-29          5
## 16 0-39g/day 30+            5
or_high <- cases_2group %>%
  filter(alcgp == "120+" | tobgp == "30+")

sum(or_high$n_cases)/sum(cases_2group$n_cases)
## [1] 0.33
(12+16+7+9+7+10+5)/(5+5+10+7+6+19+19+9+34+9+7+16+15+17+10+12)
## [1] 0.33

Question 6a

1.0/1.0 point (graded) For controls, what is the probability of being in the highest alcohol group?

Report your answer to 3 significant figures. correct

0.0284 or 0.0687 Loading

Explanation

The probability can be calculated using the following code:

      high_alc_controls <- esoph %>%

filter(alcgp == “120+”) %>% pull(ncontrols) %>% sum()

p_control_high_alc <- high_alc_controls/all_controls p_control_high_alc

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 1 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
cont_alcogroup <- esoph %>%
  filter(ncontrols != 0) %>%
  group_by(alcgp) %>%
  mutate(n_controls = sum(ncontrols)) %>%
  select(alcgp, n_controls) %>%
  unique()

cont_alcogroup
## # A tibble: 4 x 2
## # Groups:   alcgp [4]
##   alcgp     n_controls
##   <ord>          <dbl>
## 1 0-39g/day        386
## 2 40-79            280
## 3 80-119            87
## 4 120+              22
alco_high <- cont_alcogroup %>%
  filter(alcgp == "120+")

sum(alco_high$n_controls)/sum(cont_alcogroup$n_controls)
## [1] 0.0283871

Question 6b

1.0/1.0 point (graded) How many times more likely are cases than controls to be in the highest alcohol group?

Report your answer to 3 significant figures. correct

7.93 or 3.27 Loading

Explanation

This calculated using the following code:

p_case_high_alc/p_control_high_alc

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 2 of 10 attempts Some problems have options such as save, reset, hints, or show answer. These options follow the Submit button.

Keep thinking, instead of jumpping or guessing or assumption

cas_alcogroup <- esoph %>%
  filter(ncases != 0) %>%
  group_by(alcgp) %>%
  mutate(n_ncases = sum(ncases)) %>%
  select(alcgp, n_ncases) %>%
  unique()

cas_alcogroup
## # A tibble: 4 x 2
## # Groups:   alcgp [4]
##   alcgp     n_ncases
##   <ord>        <dbl>
## 1 120+            45
## 2 0-39g/day       29
## 3 40-79           75
## 4 80-119          51
cas_alcohigh <- cas_alcogroup %>%
  filter(alcgp == "120+")



con_alcogroup <- esoph %>%
  filter(ncontrols != 0) %>%
  group_by(alcgp) %>%
  mutate(n_ncontrols = sum(ncontrols)) %>%
  select(alcgp, n_ncontrols) %>%
  unique()

con_alcogroup
## # A tibble: 4 x 2
## # Groups:   alcgp [4]
##   alcgp     n_ncontrols
##   <ord>           <dbl>
## 1 0-39g/day         386
## 2 40-79             280
## 3 80-119             87
## 4 120+               22
con_alcohigh <- con_alcogroup %>%
  filter(alcgp == "120+")

(cas_alcohigh$n_ncases/sum(cas_alcogroup$n_ncases))/(con_alcohigh$n_ncontrols/sum(con_alcogroup$n_ncontrols))
## [1] 7.926136

Question 6c

1/1 point (graded) For controls, what is the probability of being in the highest tobacco group?

Report your answer to 3 significant figures. correct

0.0658 or 0.0841 Loading

Explanation

The probability can be calculated using the following code:

      high_tob_controls <- esoph %>%

filter(tobgp == “30+”) %>% pull(ncontrols) %>% sum()

p_control_high_tob <- high_tob_controls/all_controls p_control_high_tob

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 1 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
conts <- esoph %>%
  filter(ncontrols != 0)

cont_hightob <- conts %>%
  filter(tobgp == "30+")


cont_hightob
##    agegp     alcgp tobgp ncases ncontrols
## 1  25-34 0-39g/day   30+      0         5
## 2  25-34     40-79   30+      0         7
## 3  25-34    80-119   30+      0         2
## 4  25-34      120+   30+      0         2
## 5  35-44 0-39g/day   30+      0         8
## 6  35-44     40-79   30+      0         8
## 7  35-44    80-119   30+      0         1
## 8  45-54 0-39g/day   30+      0         4
## 9  45-54     40-79   30+      5         2
## 10 45-54    80-119   30+      2         2
## 11 55-64 0-39g/day   30+      4         2
## 12 55-64     40-79   30+      3         3
## 13 55-64      120+   30+      5         1
## 14 65-74 0-39g/day   30+      0         2
## 15   75+ 0-39g/day   30+      1         2
sum(cont_hightob$ncontrols)/sum(conts$ncontrols)
## [1] 0.06580645

Question 6d

1/1 point (graded) For controls, what is the probability of being in the highest alcohol group and the highest tobacco group?

Report your answer to 3 significant figures. correct

0.00387 or 0.0133 Loading

Explanation

The probability can be calculated using the following code:

      high_alc_tob_controls <- esoph %>%

filter(alcgp == “120+” & tobgp == “30+”) %>% pull(ncontrols) %>% sum()

p_control_high_alc_tob <- high_alc_tob_controls/all_controls p_control_high_alc_tob

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 1 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
conts <- esoph %>%
  filter(ncontrols != 0)

cont_2high <- conts %>%
  filter(tobgp == "30+" & alcgp == "120+")


cont_2high
##   agegp alcgp tobgp ncases ncontrols
## 1 25-34  120+   30+      0         2
## 2 55-64  120+   30+      5         1
sum(cont_2high$ncontrols)/sum(conts$ncontrols)
## [1] 0.003870968

Question 6e

1/1 point (graded) For controls, what is the probability of being in the highest alcohol group or the highest tobacco group?

Report your answer to 3 significant figures. correct

0.0903 or 0.139 Loading

Explanation

The probability can be calculated using the following code:

      p_control_either_highest <- p_control_high_alc + p_control_high_tob - p_control_high_alc_tob

p_control_either_highest

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 1 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
conts <- esoph %>%
  filter(ncontrols != 0)

cont_2high <- conts %>%
  filter(tobgp == "30+" | alcgp == "120+")


cont_2high
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day      30+      0         5
## 2  25-34     40-79      30+      0         7
## 3  25-34    80-119      30+      0         2
## 4  25-34      120+ 0-9g/day      0         1
## 5  25-34      120+    20-29      0         1
## 6  25-34      120+      30+      0         2
## 7  35-44 0-39g/day      30+      0         8
## 8  35-44     40-79      30+      0         8
## 9  35-44    80-119      30+      0         1
## 10 35-44      120+ 0-9g/day      2         1
## 11 35-44      120+    10-19      0         3
## 12 35-44      120+    20-29      2         2
## 13 45-54 0-39g/day      30+      0         4
## 14 45-54     40-79      30+      5         2
## 15 45-54    80-119      30+      2         2
## 16 45-54      120+    10-19      3         1
## 17 45-54      120+    20-29      2         1
## 18 55-64 0-39g/day      30+      4         2
## 19 55-64     40-79      30+      3         3
## 20 55-64      120+ 0-9g/day      5         5
## 21 55-64      120+    10-19      6         1
## 22 55-64      120+    20-29      2         1
## 23 55-64      120+      30+      5         1
## 24 65-74 0-39g/day      30+      0         2
## 25 65-74      120+ 0-9g/day      3         1
## 26 65-74      120+    10-19      1         1
## 27   75+ 0-39g/day      30+      1         2
sum(cont_2high$ncontrols)/sum(conts$ncontrols)
## [1] 0.09032258

Question 6f

1/1 point (graded) How many times more likely are cases than controls to be in the highest alcohol group or the highest tobacco group?

Report your answer to 3 significant figures. correct

3.65 or 2.37 Loading

Explanation

This calculated using the following code:

p_case_either_highest/p_control_either_highest

Note that depending on your version of R and the dataset you will get a different answer because of bug fixes to the dataset! You have used 3 of 10 attempts Some

esoph
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day 0-9g/day      0        40
## 2  25-34 0-39g/day    10-19      0        10
## 3  25-34 0-39g/day    20-29      0         6
## 4  25-34 0-39g/day      30+      0         5
## 5  25-34     40-79 0-9g/day      0        27
## 6  25-34     40-79    10-19      0         7
## 7  25-34     40-79    20-29      0         4
## 8  25-34     40-79      30+      0         7
## 9  25-34    80-119 0-9g/day      0         2
## 10 25-34    80-119    10-19      0         1
## 11 25-34    80-119      30+      0         2
## 12 25-34      120+ 0-9g/day      0         1
## 13 25-34      120+    10-19      1         0
## 14 25-34      120+    20-29      0         1
## 15 25-34      120+      30+      0         2
## 16 35-44 0-39g/day 0-9g/day      0        60
## 17 35-44 0-39g/day    10-19      1        13
## 18 35-44 0-39g/day    20-29      0         7
## 19 35-44 0-39g/day      30+      0         8
## 20 35-44     40-79 0-9g/day      0        35
## 21 35-44     40-79    10-19      3        20
## 22 35-44     40-79    20-29      1        13
## 23 35-44     40-79      30+      0         8
## 24 35-44    80-119 0-9g/day      0        11
## 25 35-44    80-119    10-19      0         6
## 26 35-44    80-119    20-29      0         2
## 27 35-44    80-119      30+      0         1
## 28 35-44      120+ 0-9g/day      2         1
## 29 35-44      120+    10-19      0         3
## 30 35-44      120+    20-29      2         2
## 31 45-54 0-39g/day 0-9g/day      1        45
## 32 45-54 0-39g/day    10-19      0        18
## 33 45-54 0-39g/day    20-29      0        10
## 34 45-54 0-39g/day      30+      0         4
## 35 45-54     40-79 0-9g/day      6        32
## 36 45-54     40-79    10-19      4        17
## 37 45-54     40-79    20-29      5        10
## 38 45-54     40-79      30+      5         2
## 39 45-54    80-119 0-9g/day      3        13
## 40 45-54    80-119    10-19      6         8
## 41 45-54    80-119    20-29      1         4
## 42 45-54    80-119      30+      2         2
## 43 45-54      120+ 0-9g/day      4         0
## 44 45-54      120+    10-19      3         1
## 45 45-54      120+    20-29      2         1
## 46 45-54      120+      30+      4         0
## 47 55-64 0-39g/day 0-9g/day      2        47
## 48 55-64 0-39g/day    10-19      3        19
## 49 55-64 0-39g/day    20-29      3         9
## 50 55-64 0-39g/day      30+      4         2
## 51 55-64     40-79 0-9g/day      9        31
## 52 55-64     40-79    10-19      6        15
## 53 55-64     40-79    20-29      4        13
## 54 55-64     40-79      30+      3         3
## 55 55-64    80-119 0-9g/day      9         9
## 56 55-64    80-119    10-19      8         7
## 57 55-64    80-119    20-29      3         3
## 58 55-64    80-119      30+      4         0
## 59 55-64      120+ 0-9g/day      5         5
## 60 55-64      120+    10-19      6         1
## 61 55-64      120+    20-29      2         1
## 62 55-64      120+      30+      5         1
## 63 65-74 0-39g/day 0-9g/day      5        43
## 64 65-74 0-39g/day    10-19      4        10
## 65 65-74 0-39g/day    20-29      2         5
## 66 65-74 0-39g/day      30+      0         2
## 67 65-74     40-79 0-9g/day     17        17
## 68 65-74     40-79    10-19      3         7
## 69 65-74     40-79    20-29      5         4
## 70 65-74    80-119 0-9g/day      6         7
## 71 65-74    80-119    10-19      4         8
## 72 65-74    80-119    20-29      2         1
## 73 65-74    80-119      30+      1         0
## 74 65-74      120+ 0-9g/day      3         1
## 75 65-74      120+    10-19      1         1
## 76 65-74      120+    20-29      1         0
## 77 65-74      120+      30+      1         0
## 78   75+ 0-39g/day 0-9g/day      1        17
## 79   75+ 0-39g/day    10-19      2         4
## 80   75+ 0-39g/day      30+      1         2
## 81   75+     40-79 0-9g/day      2         3
## 82   75+     40-79    10-19      1         2
## 83   75+     40-79    20-29      0         3
## 84   75+     40-79      30+      1         0
## 85   75+    80-119 0-9g/day      1         0
## 86   75+    80-119    10-19      1         0
## 87   75+      120+ 0-9g/day      2         0
## 88   75+      120+    10-19      1         0
conts <- esoph %>%
  filter(ncontrols != 0)

cont_2high <- conts %>%
  filter(tobgp == "30+" | alcgp == "120+")


cont_2high
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34 0-39g/day      30+      0         5
## 2  25-34     40-79      30+      0         7
## 3  25-34    80-119      30+      0         2
## 4  25-34      120+ 0-9g/day      0         1
## 5  25-34      120+    20-29      0         1
## 6  25-34      120+      30+      0         2
## 7  35-44 0-39g/day      30+      0         8
## 8  35-44     40-79      30+      0         8
## 9  35-44    80-119      30+      0         1
## 10 35-44      120+ 0-9g/day      2         1
## 11 35-44      120+    10-19      0         3
## 12 35-44      120+    20-29      2         2
## 13 45-54 0-39g/day      30+      0         4
## 14 45-54     40-79      30+      5         2
## 15 45-54    80-119      30+      2         2
## 16 45-54      120+    10-19      3         1
## 17 45-54      120+    20-29      2         1
## 18 55-64 0-39g/day      30+      4         2
## 19 55-64     40-79      30+      3         3
## 20 55-64      120+ 0-9g/day      5         5
## 21 55-64      120+    10-19      6         1
## 22 55-64      120+    20-29      2         1
## 23 55-64      120+      30+      5         1
## 24 65-74 0-39g/day      30+      0         2
## 25 65-74      120+ 0-9g/day      3         1
## 26 65-74      120+    10-19      1         1
## 27   75+ 0-39g/day      30+      1         2
cas <- esoph %>%
  filter(ncases != 0)

cas_2high <- cas %>%
  filter(tobgp == "30+" | alcgp == "120+")


cas_2high
##    agegp     alcgp    tobgp ncases ncontrols
## 1  25-34      120+    10-19      1         0
## 2  35-44      120+ 0-9g/day      2         1
## 3  35-44      120+    20-29      2         2
## 4  45-54     40-79      30+      5         2
## 5  45-54    80-119      30+      2         2
## 6  45-54      120+ 0-9g/day      4         0
## 7  45-54      120+    10-19      3         1
## 8  45-54      120+    20-29      2         1
## 9  45-54      120+      30+      4         0
## 10 55-64 0-39g/day      30+      4         2
## 11 55-64     40-79      30+      3         3
## 12 55-64    80-119      30+      4         0
## 13 55-64      120+ 0-9g/day      5         5
## 14 55-64      120+    10-19      6         1
## 15 55-64      120+    20-29      2         1
## 16 55-64      120+      30+      5         1
## 17 65-74    80-119      30+      1         0
## 18 65-74      120+ 0-9g/day      3         1
## 19 65-74      120+    10-19      1         1
## 20 65-74      120+    20-29      1         0
## 21 65-74      120+      30+      1         0
## 22   75+ 0-39g/day      30+      1         2
## 23   75+     40-79      30+      1         0
## 24   75+      120+ 0-9g/day      2         0
## 25   75+      120+    10-19      1         0
(sum(cas_2high$ncases)/sum(cas$ncases))/(sum(cont_2high$ncontrols)/sum(conts$ncontrols))
## [1] 3.653571
# (cas_alcohigh$n_ncases/sum(cas_alcogroup$n_ncases))/(con_alcohigh$n_ncontrols/sum(con_alcogroup$n_ncontrols))

The 1.4 Assessment: Discrete Probability were designed poorly, you are not trying hard enough, just add up similar questions

discussion posted less than a minute ago by john_hhu2020

If you can update the part, it would be a good course, but the instructor seems not really care about the statistic training he can provides to the audience. I suppose he can talked about more info about Montely Hall problem, instead of simulation